Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-03-20 11:55:40
Exec Total Coverage
Lines: 1775 4235 41.9%
Functions: 128 343 37.3%
Branches: 953 2692 35.4%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35 #include "dialog/cheatkeys.h"
36
37 #ifdef ALLEGRO_DOS
38 #include <unistd.h>
39 #endif
40
41 #include "metadata/metadata.h"
42 #include "zelda.h"
43 #include "tiles.h"
44 #include "base/colors.h"
45 #include "pal.h"
46 #include "base/zsys.h"
47 #include "qst.h"
48 #include "zc_sys.h"
49 #include "play_midi.h"
50 #include "debug.h"
51 #include "jwin_a5.h"
52 #include "base/jwinfsel.h"
53 #include "base/gui.h"
54 #include "midi.h"
55 #include "subscr.h"
56 #include "maps.h"
57 #include "sprite.h"
58 #include "guys.h"
59 #include "hero.h"
60 #include "title.h"
61 #include "particles.h"
62 #include "zconsole.h"
63 #include "ffscript.h"
64 #include "dialog/info.h"
65 #include "dialog/alert.h"
66 #include <fmt/format.h>
67
68 #ifdef __EMSCRIPTEN__
69 #include "base/emscripten_utils.h"
70 #endif
71
72 extern FFScript FFCore;
73 extern bool Playing;
74 int32_t sfx_voice[WAV_COUNT];
75 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
76 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
77
78 extern byte monochrome_console;
79
80 extern FONT *lfont;
81 extern HeroClass Hero;
82 extern FFScript FFCore;
83 extern ZModule zcm;
84 extern zcmodule moduledata;
85 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
86 extern particle_list particles;
87 extern int32_t loadlast;
88 extern word passive_subscreen_doscript;
89 extern bool passive_subscreen_waitdraw;
90 extern char *sfx_string[WAV_COUNT];
91 byte use_dwm_flush;
92 byte use_save_indicator;
93 byte midi_patch_fix;
94 bool midi_paused=false;
95 int32_t paused_midi_pos = 0;
96 byte midi_suspended = 0;
97 byte callback_switchin = 0;
98 byte zc_192b163_warp_compatibility;
99 char modulepath[2048];
100 bool epilepsyFlashReduction;
101 signed char pause_in_background_menu_init = 0;
102 byte pause_in_background = 0;
103 bool is_sys_pal = false;
104 static bool load_control_called_this_frame;
105 extern PALETTE* hw_palette;
106 extern bool update_hw_pal;
107 extern const char* dmaplist(int32_t index, int32_t* list_size);
108 int32_t getnumber(const char *prompt,int32_t initialval);
109
110 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
111 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
112 //extern byte refresh_select_screen;
113 //extern movingblock mblock2; //mblock[4]?
114 //extern int32_t db;
115
116 static const char *ZC_str = "Zelda Classic";
117 extern char save_file_name[1024];
118 #ifdef ALLEGRO_DOS
119 const char *qst_dir_name = "dos_qst_dir";
120 #elif defined(ALLEGRO_WINDOWS)
121 const char *qst_dir_name = "win_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(ALLEGRO_LINUX)
124 const char *qst_dir_name = "linux_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #elif defined(__APPLE__)
127 const char *qst_dir_name = "osx_qst_dir";
128 static const char *qst_module_name = "current_module";
129 #endif
130 #ifdef ALLEGRO_LINUX
131 static const char *samplepath = "samplesoundset/patches.dat";
132 #endif
133 char qst_files_path[2048];
134
135 #ifdef _MSC_VER
136 #define getcwd _getcwd
137 #endif
138
139 bool rF11();
140 bool rI();
141 bool rQ();
142 bool zc_key_pressed();
143
144 #ifdef _WIN32
145
146 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
147 extern "C"
148 {
149 typedef HRESULT(WINAPI *t_DwmFlush)();
150 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
151 }
152
153 void do_DwmFlush()
154 {
155 static HMODULE shell = LoadLibrary("dwmapi.dll");
156
157 if(!shell)
158 return;
159
160 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
161 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
162
163 BOOL enabled;
164 isEnabled(&enabled);
165
166 if(isEnabled)
167 flush();
168 }
169
170 #endif // _WIN32
171
172 82019 bool flash_reduction_enabled(bool check_qr)
173 {
174
4/4
✓ Branch 0 taken 79798 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 79342 times.
✓ Branch 3 taken 81563 times.
82019 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
175 }
176
177 // Dialogue largening
178 void large_dialog(DIALOG *d)
179 {
180 large_dialog(d, 1.5);
181 }
182
183 void large_dialog(DIALOG *d, float RESIZE_AMT)
184 {
185 if(!d[0].d1)
186 {
187 d[0].d1 = 1;
188 int32_t oldwidth = d[0].w;
189 int32_t oldheight = d[0].h;
190 int32_t oldx = d[0].x;
191 int32_t oldy = d[0].y;
192 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
193 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
194 d[0].w = int32_t(d[0].w*RESIZE_AMT);
195 d[0].h = int32_t(d[0].h*RESIZE_AMT);
196
197 for(int32_t i=1; d[i].proc !=NULL; i++)
198 {
199 // Place elements horizontally
200 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
201 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
202
203 if(d[i].proc != d_stringloader)
204 {
205 if(d[i].proc==d_bitmap_proc)
206 {
207 d[i].w *= 2;
208 }
209 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
210 }
211
212 // Place elements vertically
213 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
214 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
215
216 // Vertically resize elements
217 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
218 {
219 d[i].h = int32_t((double)d[i].h*1.5);
220 }
221 else if(d[i].proc == jwin_droplist_proc)
222 {
223 d[i].y += int32_t((double)d[i].h*0.25);
224 d[i].h = int32_t((double)d[i].h*1.25);
225 }
226 else if(d[i].proc==d_bitmap_proc)
227 {
228 d[i].h *= 2;
229 }
230 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
231
232 // Fix frames
233 if(d[i].proc == jwin_frame_proc)
234 {
235 d[i].x++;
236 d[i].y++;
237 d[i].w-=4;
238 d[i].h-=4;
239 }
240 }
241 }
242
243 for(int32_t i=1; d[i].proc!=NULL; i++)
244 {
245 if(d[i].proc==jwin_slider_proc)
246 continue;
247
248 // Bigger font
249 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
250
251 if(!d[i].dp2 && bigfontproc)
252 {
253 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
254 d[i].dp2 = lfont_l;
255 }
256 else if(!bigfontproc)
257 {
258 // ((ListData *)d[i].dp)->font = &sfont3;
259 ((ListData *)d[i].dp)->font = &lfont_l;
260 }
261
262 // Make checkboxes work
263 if(d[i].proc == jwin_check_proc)
264 d[i].proc = jwin_checkfont_proc;
265 else if(d[i].proc == jwin_radio_proc)
266 d[i].proc = jwin_radiofont_proc;
267 }
268
269 jwin_center_dialog(d);
270 }
271
272
273 /**********************************/
274 /******** System functions ********/
275 /**********************************/
276
277 static char cfg_sect[] = "zeldadx"; //We need to rename this.
278 static char ctrl_sect[] = "Controls";
279 static char sfx_sect[] = "Volume";
280
281 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
282 {
283 return D_O_K;
284 }
285
286 bool checkcheat(Cheat cheat)
287 {
288 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
289 return true; //Main key pressed
290 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
291 return true; //Alt key pressed
292 return false;
293 }
294 29 void load_default_cheatkeys()
295 {
296 29 memset(cheatkeys, 0, sizeof(cheatkeys));
297 29 cheatkeys[Cheat::Life][0] = KEY_H;
298 29 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
299 29 cheatkeys[Cheat::Magic][0] = KEY_M;
300 29 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
301 29 cheatkeys[Cheat::Rupies][0] = KEY_R;
302 29 cheatkeys[Cheat::Bombs][0] = KEY_B;
303 29 cheatkeys[Cheat::Arrows][0] = KEY_A;
304 29 cheatkeys[Cheat::Clock][0] = KEY_I;
305 29 cheatkeys[Cheat::Walls][0] = KEY_F11;
306 29 cheatkeys[Cheat::Fast][0] = KEY_Q;
307 29 cheatkeys[Cheat::Light][0] = KEY_L;
308 29 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
309 29 cheatkeys[Cheat::Kill][0] = KEY_K;
310 29 cheatkeys[Cheat::GoTo][0] = KEY_G;
311 29 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
312 29 cheatkeys[Cheat::ShowL0][0] = KEY_0;
313 29 cheatkeys[Cheat::ShowL1][0] = KEY_1;
314 29 cheatkeys[Cheat::ShowL2][0] = KEY_2;
315 29 cheatkeys[Cheat::ShowL3][0] = KEY_3;
316 29 cheatkeys[Cheat::ShowL4][0] = KEY_4;
317 29 cheatkeys[Cheat::ShowL5][0] = KEY_5;
318 29 cheatkeys[Cheat::ShowL6][0] = KEY_6;
319 29 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
320 29 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
321 29 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
322 29 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
323 29 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
324 29 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
325 29 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
326 29 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
327 29 }
328 29 void load_game_configs()
329 {
330 29 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
331 29 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
332 29 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
333 29 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
334 29 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
335 29 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
336 29 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
337 29 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
338 29 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
339 29 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
340 29 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
341 29 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
342 29 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
343 29 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
344 29 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
345
346 //cheat modifier keya
347 29 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
348 29 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
349 29 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
350 29 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
351
352 //cheat keys
353 29 load_default_cheatkeys();
354 char buf[256];
355 29 al_trace("START CHEATS\n");
356
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 29 times.
1044 for(size_t q = 1; q < Cheat::Last; ++q)
357 {
358
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 if(!bindable_cheat((Cheat)q)) continue;
359 1015 std::string cheatname = cheat_to_string((Cheat)q);
360
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 util::lowerstr(cheatname);
361 1015 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
362
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 al_trace("%s = %d\n", buf, cheatkeys[q][0]);
363
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
364 1015 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
365
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 al_trace("%s = %d\n", buf, cheatkeys[q][1]);
366
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
367 1015 }
368 29 al_trace("END CHEATS\n");
369
370
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
371 joystick_index = 0;
372
373 29 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
374 29 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
375 29 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
376 29 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
377 29 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
378 29 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
379 29 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
380 29 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
381 29 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
382 29 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
383
384 29 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
385 29 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
386 29 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
387 29 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
388
389 29 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
390 29 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
391 29 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
392 29 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
393 29 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
394 29 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
395 29 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
396 29 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
397 29 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
398 29 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
399 29 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
400
401 29 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
402 29 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
403 29 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
404 29 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
405
406 29 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
407
408 29 digi_volume = zc_get_config(sfx_sect,"digi",248);
409 29 midi_volume = zc_get_config(sfx_sect,"midi",255);
410 29 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
411 29 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
412 29 pan_style = zc_get_config(sfx_sect,"pan",1);
413 // 1 <= zcmusic_bufsz <= 128
414 29 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
415 29 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
416 29 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
417 29 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
418 29 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
419 29 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
420 29 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
421 #ifdef __EMSCRIPTEN__
422 if (em_is_mobile()) NameEntryMode = 2;
423 #endif
424 29 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
425 29 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
426 29 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
427 29 title_version = zc_get_config(cfg_sect,"title",2);
428 29 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
429 29 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
430
431 //default - scale x2, 640 x 480
432 29 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
433 29 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
434 29 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
435 29 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
436 29 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
437 29 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
438
439 29 loadlast = zc_get_config(cfg_sect,"load_last",0);
440
441 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
442
443 29 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
444
445 29 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
446 29 info_opacity = zc_get_config("zc","debug_info_opacity",255);
447 #ifdef _WIN32
448 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
449 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
450 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
451 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
452
453 // This one's for Aero
454 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
455
456 // And this one fixes patches unloading on some MIDI setups
457 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
458 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
459 #else //UNIX
460 29 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
461 29 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
462 29 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
463 #endif
464 29 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
465 29 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
466
467 29 char const* default_path = "";
468 29 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
469
470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(strlen(qstdir)==0)
471 {
472 29 getcwd(qstdir,2048);
473 29 fix_filename_case(qstdir);
474 29 fix_filename_slashes(qstdir);
475 29 put_backslash(qstdir);
476 29 }
477 else
478 {
479 chop_path(qstdir);
480 }
481
482 29 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
483 29 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
484 29 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
485 29 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
486 29 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
487 29 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
488 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
489 29 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
490 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
491 29 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
492 29 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
493 29 }
494
495 void save_control_configs(bool kb)
496 {
497 if(kb)
498 {
499 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
500 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
501 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
502 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
503
504 if (!replay_is_replaying())
505 {
506 zc_set_config(ctrl_sect,"key_a",Akey);
507 zc_set_config(ctrl_sect,"key_b",Bkey);
508 zc_set_config(ctrl_sect,"key_s",Skey);
509 zc_set_config(ctrl_sect,"key_l",Lkey);
510 zc_set_config(ctrl_sect,"key_r",Rkey);
511 zc_set_config(ctrl_sect,"key_p",Pkey);
512 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
513 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
514 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
515 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
516 zc_set_config(ctrl_sect,"key_up", DUkey);
517 zc_set_config(ctrl_sect,"key_down", DDkey);
518 zc_set_config(ctrl_sect,"key_left", DLkey);
519 zc_set_config(ctrl_sect,"key_right",DRkey);
520 }
521 }
522 else
523 {
524 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
525 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
526 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
527 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
528 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
529 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
530 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
531 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
532 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
533 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
534 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
535 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
536 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
537 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
538
539 zc_set_config(ctrl_sect,"btn_a",Abtn);
540 zc_set_config(ctrl_sect,"btn_b",Bbtn);
541 zc_set_config(ctrl_sect,"btn_s",Sbtn);
542 zc_set_config(ctrl_sect,"btn_m",Mbtn);
543 zc_set_config(ctrl_sect,"btn_l",Lbtn);
544 zc_set_config(ctrl_sect,"btn_r",Rbtn);
545 zc_set_config(ctrl_sect,"btn_p",Pbtn);
546 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
547 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
548 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
549 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
550
551 zc_set_config(ctrl_sect,"btn_up",DUbtn);
552 zc_set_config(ctrl_sect,"btn_down",DDbtn);
553 zc_set_config(ctrl_sect,"btn_left",DLbtn);
554 zc_set_config(ctrl_sect,"btn_right",DRbtn);
555 }
556 }
557
558 void save_cheatkeys()
559 {
560 char buf[256];
561 for(size_t q = 1; q < Cheat::Last; ++q)
562 {
563 if(!bindable_cheat((Cheat)q)) continue;
564 std::string cheatname = cheat_to_string((Cheat)q);
565 util::lowerstr(cheatname);
566 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
567 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
568 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
569 if(cheatkeys[q][1])
570 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
571 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
572 }
573 }
574
575 void save_game_configs()
576 {
577 packfile_password("");
578
579 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
580
581 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
582 {
583 int o_window_x, o_window_y;
584 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
585 zc_set_config(cfg_sect,"window_x",o_window_x);
586 zc_set_config(cfg_sect,"window_y",o_window_y);
587 }
588
589 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
590 {
591 double monitor_scale = zc_get_monitor_scale();
592 window_width = al_get_display_width(all_get_display()) / monitor_scale;
593 window_height = al_get_display_height(all_get_display()) / monitor_scale;
594 zc_set_config(cfg_sect,"window_width",window_width);
595 zc_set_config(cfg_sect,"window_height",window_height);
596 }
597
598 zc_set_config(cfg_sect,"load_last",loadlast);
599 chop_path(qstdir);
600 zc_set_config(cfg_sect,qst_dir_name,qstdir);
601 zc_set_config("SAVEFILE","save_filename",save_file_name);
602 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
603
604 flush_config_file();
605 #ifdef __EMSCRIPTEN__
606 em_sync_fs();
607 #endif
608 }
609
610 //----------------------------------------------------------------
611
612 // Timers
613
614 27794 void fps_callback()
615 {
616 27794 lastfps=framecnt;
617 27794 dword tempsecs = fps_secs;
618 27794 ++tempsecs;
619 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
620 27794 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
621 27794 ++fps_secs;
622 27794 framecnt=0;
623 27794 }
624
625 END_OF_FUNCTION(fps_callback)
626
627 29 int32_t Z_init_timers()
628 {
629 static bool didit = false;
630 const static char *err_str = "Couldn't allocate timer";
631 29 err_str = err_str; //Unused variable warning
632
633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(didit)
634 return 1;
635
636 29 didit = true;
637
638 LOCK_VARIABLE(lastfps);
639 LOCK_VARIABLE(framecnt);
640 LOCK_FUNCTION(fps_callback);
641
642
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
643 return 0;
644
645 29 return 1;
646 29 }
647
648 void Z_remove_timers()
649 {
650 remove_int(fps_callback);
651 }
652
653 //----------------------------------------------------------------
654
655 void go()
656 {
657 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
658 }
659
660 void comeback()
661 {
662 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
663 }
664
665 void dump_pal(BITMAP *dest)
666 {
667 for(int32_t i=0; i<256; i++)
668 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
669 }
670
671 //----------------------------------------------------------------
672
673 //Handles converting the mouse sprite from the .dat file
674 29 void load_mouse()
675 {
676 29 system_pal();
677 29 MouseSprite::set(-1);
678 29 int32_t sz = vbound(int32_t(16*(zc_get_config("zeldadx","cursor_scale_large",1.5))),16,80);
679
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t j = 0; j < 4; ++j)
680 {
681 116 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
682 116 BITMAP* subbmp = create_bitmap_ex(8,16,16);
683
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(zcmouse[j])
684 destroy_bitmap(zcmouse[j]);
685 116 zcmouse[j] = create_bitmap_ex(8,sz,sz);
686 116 clear_bitmap(zcmouse[j]);
687 116 clear_bitmap(tmpbmp);
688 116 clear_bitmap(subbmp);
689 116 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
690
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 116 times.
1972 for(int32_t x = 0; x < 16; ++x)
691 {
692
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 1856 times.
31552 for(int32_t y = 0; y < 16; ++y)
693 {
694 29696 int32_t color = getpixel(tmpbmp, x, y);
695
5/5
✓ Branch 0 taken 27318 times.
✓ Branch 1 taken 551 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 667 times.
✓ Branch 4 taken 522 times.
29696 switch(color)
696 {
697 case dvc(1):
698 551 color = jwin_pal[jcCURSORMISC];
699 551 break;
700 case dvc(2):
701 638 color = jwin_pal[jcCURSOROUTLINE];
702 638 break;
703 case dvc(3):
704 667 color = jwin_pal[jcCURSORLIGHT];
705 667 break;
706 case dvc(5):
707 522 color = jwin_pal[jcCURSORDARK];
708 522 break;
709 }
710 29696 putpixel(subbmp, x, y, color);
711 29696 }
712 1856 }
713
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(sz!=16)
714 116 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
715 else
716 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
717 116 destroy_bitmap(tmpbmp);
718 116 destroy_bitmap(subbmp);
719 116 }
720 29 zc_set_palette(*hw_palette);
721
722 29 MouseSprite::assign(0, zcmouse[0]);
723 29 MouseSprite::set(0);
724
725 29 game_pal();
726 29 }
727
728 // sets the video mode and initializes the palette and mouse sprite
729 29 bool game_vid_mode(int32_t mode,int32_t wait)
730 {
731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
732 {
733 return false;
734 }
735
736 29 scrx = (resx-320)>>1;
737 29 scry = (resy-240)>>1;
738
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
739 116 zcmouse[q] = NULL;
740 29 load_mouse();
741
742
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 29 times.
493 for(int32_t i=240; i<256; i++)
743 464 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
744
745 29 zc_set_palette(RAMpal);
746 29 clear_to_color(screen,BLACK);
747
748 29 rest(wait);
749 29 return true;
750 29 }
751
752 5 void null_quest()
753 {
754 char qstdat_string[2048];
755 5 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
756 5 strcat(qstdat_string,"#NESQST_NEW_QST");
757
758 #ifdef __EMSCRIPTEN__
759 // The quest template data file is not included because it's really big and isn't really needed
760 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
761 // which is much smaller.
762 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
763 #endif
764
765 5 byte skip_flags[4] = { 0 };
766
767 5 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
768 5 }
769
770 5 void init_NES_mode()
771 {
772 /*
773 // qst.dat may not load correctly without this...
774 QHeader.templatepath[0]='\0';
775
776 if(!init_colordata(true, &QHeader, &QMisc))
777 {
778 return;
779 }
780
781 loadfullpal();
782 init_tiles(false, &QHeader);
783 */
784 5 null_quest();
785 5 }
786
787 //----------------------------------------------------------------
788
789 qword trianglelines[16]=
790 {
791 0x0000000000000000ULL,
792 0xFD00000000000000ULL,
793 0xFDFD000000000000ULL,
794 0xFDFDFD0000000000ULL,
795 0xFDFDFDFD00000000ULL,
796 0xFDFDFDFDFD000000ULL,
797 0xFDFDFDFDFDFD0000ULL,
798 0xFDFDFDFDFDFDFD00ULL,
799 0xFDFDFDFDFDFDFDFDULL,
800 0x00FDFDFDFDFDFDFDULL,
801 0x0000FDFDFDFDFDFDULL,
802 0x000000FDFDFDFDFDULL,
803 0x00000000FDFDFDFDULL,
804 0x0000000000FDFDFDULL,
805 0x000000000000FDFDULL,
806 0x00000000000000FDULL,
807 };
808
809 word screen_triangles[28][32];
810 /*
811 qword triangles[4][16]= //[direction][value]
812 {
813 {
814 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
815 },
816 {
817 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
818 },
819 {
820 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
821 },
822 {
823 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
824 }
825 };
826 */
827
828
829 /*
830 byte triangles[4][16][8]= //[direction][value][line]
831 {
832 {
833 {
834 0, 0, 0, 0, 0, 0, 0, 0
835 },
836 {
837 1, 0, 0, 0, 0, 0, 0, 0
838 },
839 {
840 2, 1, 0, 0, 0, 0, 0, 0
841 },
842 {
843 3, 2, 1, 0, 0, 0, 0, 0
844 },
845 {
846 4, 3, 2, 1, 0, 0, 0, 0
847 },
848 {
849 5, 4, 3, 2, 1, 0, 0, 0
850 },
851 {
852 6, 5, 4, 3, 2, 1, 0, 0
853 },
854 {
855 7, 6, 5, 4, 3, 2, 1, 0
856 },
857 {
858 8, 7, 6, 5, 4, 3, 2, 1
859 },
860 {
861 8, 8, 7, 6, 5, 4, 3, 2
862 },
863 {
864 8, 8, 8, 7, 6, 5, 4, 3
865 },
866 {
867 8, 8, 8, 8, 7, 6, 5, 4
868 },
869 {
870 8, 8, 8, 8, 8, 7, 6, 5
871 },
872 {
873 8, 8, 8, 8, 8, 8, 7, 6
874 },
875 {
876 8, 8, 8, 8, 8, 8, 8, 7
877 },
878 {
879 8, 8, 8, 8, 8, 8, 8, 8
880 }
881 },
882 {
883 {
884 0, 0, 0, 0, 0, 0, 0, 0
885 },
886 {
887 15, 0, 0, 0, 0, 0, 0, 0
888 },
889 {
890 14, 15, 0, 0, 0, 0, 0, 0
891 },
892 {
893 13, 14, 15, 0, 0, 0, 0, 0
894 },
895 {
896 12, 13, 14, 15, 0, 0, 0, 0
897 },
898 {
899 11, 12, 13, 14, 15, 0, 0, 0
900 },
901 {
902 10, 11, 12, 13, 14, 15, 0, 0
903 },
904 {
905 9, 10, 11, 12, 13, 14, 15, 0
906 },
907 {
908 8, 9, 10, 11, 12, 13, 14, 15
909 },
910 {
911 8, 8, 9, 10, 11, 12, 13, 14
912 },
913 {
914 8, 8, 8, 9, 10, 11, 12, 13
915 },
916 {
917 8, 8, 8, 8, 9, 10, 11, 12
918 },
919 {
920 8, 8, 8, 8, 8, 9, 10, 11
921 },
922 {
923 8, 8, 8, 8, 8, 8, 9, 10
924 },
925 {
926 8, 8, 8, 8, 8, 8, 8, 9
927 },
928 {
929 8, 8, 8, 8, 8, 8, 8, 8
930 }
931 },
932 {
933 {
934 0, 0, 0, 0, 0, 0, 0, 0
935 },
936 {
937 0, 0, 0, 0, 0, 0, 0, 1
938 },
939 {
940 0, 0, 0, 0, 0, 0, 1, 2
941 },
942 {
943 0, 0, 0, 0, 0, 1, 2, 3
944 },
945 {
946 0, 0, 0, 0, 1, 2, 3, 4
947 },
948 {
949 0, 0, 0, 1, 2, 3, 4, 5
950 },
951 {
952 0, 0, 1, 2, 3, 4, 5, 6
953 },
954 {
955 0, 1, 2, 3, 4, 5, 6, 7
956 },
957 {
958 1, 2, 3, 4, 5, 6, 7, 8
959 },
960 {
961 2, 3, 4, 5, 6, 7, 8, 8
962 },
963 {
964 3, 4, 5, 6, 7, 8, 8, 8
965 },
966 {
967 4, 5, 6, 7, 8, 8, 8, 8
968 },
969 {
970 5, 6, 7, 8, 8, 8, 8, 8
971 },
972 {
973 6, 7, 8, 8, 8, 8, 8, 8
974 },
975 {
976 7, 8, 8, 8, 8, 8, 8, 8
977 },
978 {
979 8, 8, 8, 8, 8, 8, 8, 8
980 }
981 },
982 {
983 {
984 0, 0, 0, 0, 0, 0, 0, 0
985 },
986 {
987 0, 0, 0, 0, 0, 0, 0, 15
988 },
989 {
990 0, 0, 0, 0, 0, 0, 15, 14
991 },
992 {
993 0, 0, 0, 0, 0, 15, 14, 13
994 },
995 {
996 0, 0, 0, 0, 15, 14, 13, 12
997 },
998 {
999 0, 0, 0, 15, 14, 13, 12, 11
1000 },
1001 {
1002 0, 0, 15, 14, 13, 12, 11, 10
1003 },
1004 {
1005 0, 15, 14, 13, 12, 11, 10, 9
1006 },
1007 {
1008 15, 14, 13, 12, 11, 10, 9, 8
1009 },
1010 {
1011 14, 13, 12, 11, 10, 9, 8, 8
1012 },
1013 {
1014 13, 12, 11, 10, 9, 8, 8, 8
1015 },
1016 {
1017 12, 11, 10, 9, 8, 8, 8, 8
1018 },
1019 {
1020 11, 10, 9, 8, 8, 8, 8, 8
1021 },
1022 {
1023 10, 9, 8, 8, 8, 8, 8, 8
1024 },
1025 {
1026 9, 8, 8, 8, 8, 8, 8, 8
1027 },
1028 {
1029 8, 8, 8, 8, 8, 8, 8, 8
1030 }
1031 }
1032 };
1033 */
1034
1035
1036
1037 /*
1038 for (int32_t blockrow=0; blockrow<30; ++i)
1039 {
1040 for (int32_t linerow=0; linerow<8; ++i)
1041 {
1042 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1043 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1044 {
1045 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1046 ++triangleline;
1047 }
1048 }
1049 }
1050 */
1051
1052 // the ULL suffixes are to prevent this warning:
1053 // warning: integer constant is too large for "int32_t" type
1054
1055 qword triangles[4][16][8]= //[direction][value][line]
1056 {
1057 {
1058 {
1059 0x0000000000000000ULL,
1060 0x0000000000000000ULL,
1061 0x0000000000000000ULL,
1062 0x0000000000000000ULL,
1063 0x0000000000000000ULL,
1064 0x0000000000000000ULL,
1065 0x0000000000000000ULL,
1066 0x0000000000000000ULL
1067 },
1068 {
1069 0xFD00000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL,
1074 0x0000000000000000ULL,
1075 0x0000000000000000ULL,
1076 0x0000000000000000ULL
1077 },
1078 {
1079 0xFDFD000000000000ULL,
1080 0xFD00000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL,
1084 0x0000000000000000ULL,
1085 0x0000000000000000ULL,
1086 0x0000000000000000ULL
1087 },
1088 {
1089 0xFDFDFD0000000000ULL,
1090 0xFDFD000000000000ULL,
1091 0xFD00000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL,
1095 0x0000000000000000ULL,
1096 0x0000000000000000ULL
1097 },
1098 {
1099 0xFDFDFDFD00000000ULL,
1100 0xFDFDFD0000000000ULL,
1101 0xFDFD000000000000ULL,
1102 0xFD00000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL,
1106 0x0000000000000000ULL
1107 },
1108 {
1109 0xFDFDFDFDFD000000ULL,
1110 0xFDFDFDFD00000000ULL,
1111 0xFDFDFD0000000000ULL,
1112 0xFDFD000000000000ULL,
1113 0xFD00000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL,
1116 0x0000000000000000ULL
1117 },
1118 {
1119 0xFDFDFDFDFDFD0000ULL,
1120 0xFDFDFDFDFD000000ULL,
1121 0xFDFDFDFD00000000ULL,
1122 0xFDFDFD0000000000ULL,
1123 0xFDFD000000000000ULL,
1124 0xFD00000000000000ULL,
1125 0x0000000000000000ULL,
1126 0x0000000000000000ULL
1127 },
1128 {
1129 0xFDFDFDFDFDFDFD00ULL,
1130 0xFDFDFDFDFDFD0000ULL,
1131 0xFDFDFDFDFD000000ULL,
1132 0xFDFDFDFD00000000ULL,
1133 0xFDFDFD0000000000ULL,
1134 0xFDFD000000000000ULL,
1135 0xFD00000000000000ULL,
1136 0x0000000000000000ULL
1137 },
1138 {
1139 0xFDFDFDFDFDFDFDFDULL,
1140 0xFDFDFDFDFDFDFD00ULL,
1141 0xFDFDFDFDFDFD0000ULL,
1142 0xFDFDFDFDFD000000ULL,
1143 0xFDFDFDFD00000000ULL,
1144 0xFDFDFD0000000000ULL,
1145 0xFDFD000000000000ULL,
1146 0xFD00000000000000ULL
1147 },
1148 {
1149 0xFDFDFDFDFDFDFDFDULL,
1150 0xFDFDFDFDFDFDFDFDULL,
1151 0xFDFDFDFDFDFDFD00ULL,
1152 0xFDFDFDFDFDFD0000ULL,
1153 0xFDFDFDFDFD000000ULL,
1154 0xFDFDFDFD00000000ULL,
1155 0xFDFDFD0000000000ULL,
1156 0xFDFD000000000000ULL
1157 },
1158 {
1159 0xFDFDFDFDFDFDFDFDULL,
1160 0xFDFDFDFDFDFDFDFDULL,
1161 0xFDFDFDFDFDFDFDFDULL,
1162 0xFDFDFDFDFDFDFD00ULL,
1163 0xFDFDFDFDFDFD0000ULL,
1164 0xFDFDFDFDFD000000ULL,
1165 0xFDFDFDFD00000000ULL,
1166 0xFDFDFD0000000000ULL
1167 },
1168 {
1169 0xFDFDFDFDFDFDFDFDULL,
1170 0xFDFDFDFDFDFDFDFDULL,
1171 0xFDFDFDFDFDFDFDFDULL,
1172 0xFDFDFDFDFDFDFDFDULL,
1173 0xFDFDFDFDFDFDFD00ULL,
1174 0xFDFDFDFDFDFD0000ULL,
1175 0xFDFDFDFDFD000000ULL,
1176 0xFDFDFDFD00000000ULL
1177 },
1178 {
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFDFDULL,
1182 0xFDFDFDFDFDFDFDFDULL,
1183 0xFDFDFDFDFDFDFDFDULL,
1184 0xFDFDFDFDFDFDFD00ULL,
1185 0xFDFDFDFDFDFD0000ULL,
1186 0xFDFDFDFDFD000000ULL
1187 },
1188 {
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFDFDULL,
1193 0xFDFDFDFDFDFDFDFDULL,
1194 0xFDFDFDFDFDFDFDFDULL,
1195 0xFDFDFDFDFDFDFD00ULL,
1196 0xFDFDFDFDFDFD0000ULL
1197 },
1198 {
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFDFDULL,
1204 0xFDFDFDFDFDFDFDFDULL,
1205 0xFDFDFDFDFDFDFDFDULL,
1206 0xFDFDFDFDFDFDFD00ULL
1207 },
1208 {
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFDFDULL,
1215 0xFDFDFDFDFDFDFDFDULL,
1216 0xFDFDFDFDFDFDFDFDULL
1217 }
1218 },
1219 {
1220 {
1221 0x0000000000000000ULL,
1222 0x0000000000000000ULL,
1223 0x0000000000000000ULL,
1224 0x0000000000000000ULL,
1225 0x0000000000000000ULL,
1226 0x0000000000000000ULL,
1227 0x0000000000000000ULL,
1228 0x0000000000000000ULL
1229 },
1230 {
1231 0x00000000000000FDULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL,
1236 0x0000000000000000ULL,
1237 0x0000000000000000ULL,
1238 0x0000000000000000ULL
1239 },
1240 {
1241 0x000000000000FDFDULL,
1242 0x00000000000000FDULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL,
1246 0x0000000000000000ULL,
1247 0x0000000000000000ULL,
1248 0x0000000000000000ULL
1249 },
1250 {
1251 0x0000000000FDFDFDULL,
1252 0x000000000000FDFDULL,
1253 0x00000000000000FDULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL,
1257 0x0000000000000000ULL,
1258 0x0000000000000000ULL
1259 },
1260 {
1261 0x00000000FDFDFDFDULL,
1262 0x0000000000FDFDFDULL,
1263 0x000000000000FDFDULL,
1264 0x00000000000000FDULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL,
1268 0x0000000000000000ULL
1269 },
1270 {
1271 0x000000FDFDFDFDFDULL,
1272 0x00000000FDFDFDFDULL,
1273 0x0000000000FDFDFDULL,
1274 0x000000000000FDFDULL,
1275 0x00000000000000FDULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL,
1278 0x0000000000000000ULL
1279 },
1280 {
1281 0x0000FDFDFDFDFDFDULL,
1282 0x000000FDFDFDFDFDULL,
1283 0x00000000FDFDFDFDULL,
1284 0x0000000000FDFDFDULL,
1285 0x000000000000FDFDULL,
1286 0x00000000000000FDULL,
1287 0x0000000000000000ULL,
1288 0x0000000000000000ULL
1289 },
1290 {
1291 0x00FDFDFDFDFDFDFDULL,
1292 0x0000FDFDFDFDFDFDULL,
1293 0x000000FDFDFDFDFDULL,
1294 0x00000000FDFDFDFDULL,
1295 0x0000000000FDFDFDULL,
1296 0x000000000000FDFDULL,
1297 0x00000000000000FDULL,
1298 0x0000000000000000ULL
1299 },
1300 {
1301 0xFDFDFDFDFDFDFDFDULL,
1302 0x00FDFDFDFDFDFDFDULL,
1303 0x0000FDFDFDFDFDFDULL,
1304 0x000000FDFDFDFDFDULL,
1305 0x00000000FDFDFDFDULL,
1306 0x0000000000FDFDFDULL,
1307 0x000000000000FDFDULL,
1308 0x00000000000000FDULL
1309 },
1310 {
1311 0xFDFDFDFDFDFDFDFDULL,
1312 0xFDFDFDFDFDFDFDFDULL,
1313 0x00FDFDFDFDFDFDFDULL,
1314 0x0000FDFDFDFDFDFDULL,
1315 0x000000FDFDFDFDFDULL,
1316 0x00000000FDFDFDFDULL,
1317 0x0000000000FDFDFDULL,
1318 0x000000000000FDFDULL
1319 },
1320 {
1321 0xFDFDFDFDFDFDFDFDULL,
1322 0xFDFDFDFDFDFDFDFDULL,
1323 0xFDFDFDFDFDFDFDFDULL,
1324 0x00FDFDFDFDFDFDFDULL,
1325 0x0000FDFDFDFDFDFDULL,
1326 0x000000FDFDFDFDFDULL,
1327 0x00000000FDFDFDFDULL,
1328 0x0000000000FDFDFDULL
1329 },
1330 {
1331 0xFDFDFDFDFDFDFDFDULL,
1332 0xFDFDFDFDFDFDFDFDULL,
1333 0xFDFDFDFDFDFDFDFDULL,
1334 0xFDFDFDFDFDFDFDFDULL,
1335 0x00FDFDFDFDFDFDFDULL,
1336 0x0000FDFDFDFDFDFDULL,
1337 0x000000FDFDFDFDFDULL,
1338 0x00000000FDFDFDFDULL
1339 },
1340 {
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0xFDFDFDFDFDFDFDFDULL,
1344 0xFDFDFDFDFDFDFDFDULL,
1345 0xFDFDFDFDFDFDFDFDULL,
1346 0x00FDFDFDFDFDFDFDULL,
1347 0x0000FDFDFDFDFDFDULL,
1348 0x000000FDFDFDFDFDULL
1349 },
1350 {
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0xFDFDFDFDFDFDFDFDULL,
1355 0xFDFDFDFDFDFDFDFDULL,
1356 0xFDFDFDFDFDFDFDFDULL,
1357 0x00FDFDFDFDFDFDFDULL,
1358 0x0000FDFDFDFDFDFDULL
1359 },
1360 {
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0xFDFDFDFDFDFDFDFDULL,
1366 0xFDFDFDFDFDFDFDFDULL,
1367 0xFDFDFDFDFDFDFDFDULL,
1368 0x00FDFDFDFDFDFDFDULL
1369 },
1370 {
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0xFDFDFDFDFDFDFDFDULL,
1377 0xFDFDFDFDFDFDFDFDULL,
1378 0xFDFDFDFDFDFDFDFDULL
1379 }
1380 },
1381 {
1382 {
1383 0x0000000000000000ULL,
1384 0x0000000000000000ULL,
1385 0x0000000000000000ULL,
1386 0x0000000000000000ULL,
1387 0x0000000000000000ULL,
1388 0x0000000000000000ULL,
1389 0x0000000000000000ULL,
1390 0x0000000000000000ULL
1391 },
1392 {
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL,
1399 0x0000000000000000ULL,
1400 0xFD00000000000000ULL
1401 },
1402 {
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0x0000000000000000ULL,
1408 0x0000000000000000ULL,
1409 0xFD00000000000000ULL,
1410 0xFDFD000000000000ULL
1411 },
1412 {
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0x0000000000000000ULL,
1418 0xFD00000000000000ULL,
1419 0xFDFD000000000000ULL,
1420 0xFDFDFD0000000000ULL
1421 },
1422 {
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0xFD00000000000000ULL,
1428 0xFDFD000000000000ULL,
1429 0xFDFDFD0000000000ULL,
1430 0xFDFDFDFD00000000ULL
1431 },
1432 {
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0xFD00000000000000ULL,
1437 0xFDFD000000000000ULL,
1438 0xFDFDFD0000000000ULL,
1439 0xFDFDFDFD00000000ULL,
1440 0xFDFDFDFDFD000000ULL
1441 },
1442 {
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0xFD00000000000000ULL,
1446 0xFDFD000000000000ULL,
1447 0xFDFDFD0000000000ULL,
1448 0xFDFDFDFD00000000ULL,
1449 0xFDFDFDFDFD000000ULL,
1450 0xFDFDFDFDFDFD0000ULL
1451 },
1452 {
1453 0x0000000000000000ULL,
1454 0xFD00000000000000ULL,
1455 0xFDFD000000000000ULL,
1456 0xFDFDFD0000000000ULL,
1457 0xFDFDFDFD00000000ULL,
1458 0xFDFDFDFDFD000000ULL,
1459 0xFDFDFDFDFDFD0000ULL,
1460 0xFDFDFDFDFDFDFD00ULL
1461 },
1462 {
1463 0xFD00000000000000ULL,
1464 0xFDFD000000000000ULL,
1465 0xFDFDFD0000000000ULL,
1466 0xFDFDFDFD00000000ULL,
1467 0xFDFDFDFDFD000000ULL,
1468 0xFDFDFDFDFDFD0000ULL,
1469 0xFDFDFDFDFDFDFD00ULL,
1470 0xFDFDFDFDFDFDFDFDULL
1471 },
1472 {
1473 0xFDFD000000000000ULL,
1474 0xFDFDFD0000000000ULL,
1475 0xFDFDFDFD00000000ULL,
1476 0xFDFDFDFDFD000000ULL,
1477 0xFDFDFDFDFDFD0000ULL,
1478 0xFDFDFDFDFDFDFD00ULL,
1479 0xFDFDFDFDFDFDFDFDULL,
1480 0xFDFDFDFDFDFDFDFDULL
1481 },
1482 {
1483 0xFDFDFD0000000000ULL,
1484 0xFDFDFDFD00000000ULL,
1485 0xFDFDFDFDFD000000ULL,
1486 0xFDFDFDFDFDFD0000ULL,
1487 0xFDFDFDFDFDFDFD00ULL,
1488 0xFDFDFDFDFDFDFDFDULL,
1489 0xFDFDFDFDFDFDFDFDULL,
1490 0xFDFDFDFDFDFDFDFDULL
1491 },
1492 {
1493 0xFDFDFDFD00000000ULL,
1494 0xFDFDFDFDFD000000ULL,
1495 0xFDFDFDFDFDFD0000ULL,
1496 0xFDFDFDFDFDFDFD00ULL,
1497 0xFDFDFDFDFDFDFDFDULL,
1498 0xFDFDFDFDFDFDFDFDULL,
1499 0xFDFDFDFDFDFDFDFDULL,
1500 0xFDFDFDFDFDFDFDFDULL
1501 },
1502 {
1503 0xFDFDFDFDFD000000ULL,
1504 0xFDFDFDFDFDFD0000ULL,
1505 0xFDFDFDFDFDFDFD00ULL,
1506 0xFDFDFDFDFDFDFDFDULL,
1507 0xFDFDFDFDFDFDFDFDULL,
1508 0xFDFDFDFDFDFDFDFDULL,
1509 0xFDFDFDFDFDFDFDFDULL,
1510 0xFDFDFDFDFDFDFDFDULL
1511 },
1512 {
1513 0xFDFDFDFDFDFD0000ULL,
1514 0xFDFDFDFDFDFDFD00ULL,
1515 0xFDFDFDFDFDFDFDFDULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL,
1520 0xFDFDFDFDFDFDFDFDULL
1521 },
1522 {
1523 0xFDFDFDFDFDFDFD00ULL,
1524 0xFDFDFDFDFDFDFDFDULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL,
1530 0xFDFDFDFDFDFDFDFDULL
1531 },
1532 {
1533 0xFDFDFDFDFDFDFDFDULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL,
1540 0xFDFDFDFDFDFDFDFDULL
1541 }
1542 },
1543 {
1544 {
1545 0x0000000000000000ULL,
1546 0x0000000000000000ULL,
1547 0x0000000000000000ULL,
1548 0x0000000000000000ULL,
1549 0x0000000000000000ULL,
1550 0x0000000000000000ULL,
1551 0x0000000000000000ULL,
1552 0x0000000000000000ULL
1553 },
1554 {
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL,
1561 0x0000000000000000ULL,
1562 0x00000000000000FDULL
1563 },
1564 {
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x0000000000000000ULL,
1570 0x0000000000000000ULL,
1571 0x00000000000000FDULL,
1572 0x000000000000FDFDULL
1573 },
1574 {
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x0000000000000000ULL,
1580 0x00000000000000FDULL,
1581 0x000000000000FDFDULL,
1582 0x0000000000FDFDFDULL
1583 },
1584 {
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x00000000000000FDULL,
1590 0x000000000000FDFDULL,
1591 0x0000000000FDFDFDULL,
1592 0x00000000FDFDFDFDULL
1593 },
1594 {
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x00000000000000FDULL,
1599 0x000000000000FDFDULL,
1600 0x0000000000FDFDFDULL,
1601 0x00000000FDFDFDFDULL,
1602 0x000000FDFDFDFDFDULL
1603 },
1604 {
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x00000000000000FDULL,
1608 0x000000000000FDFDULL,
1609 0x0000000000FDFDFDULL,
1610 0x00000000FDFDFDFDULL,
1611 0x000000FDFDFDFDFDULL,
1612 0x0000FDFDFDFDFDFDULL
1613 },
1614 {
1615 0x0000000000000000ULL,
1616 0x00000000000000FDULL,
1617 0x000000000000FDFDULL,
1618 0x0000000000FDFDFDULL,
1619 0x00000000FDFDFDFDULL,
1620 0x000000FDFDFDFDFDULL,
1621 0x0000FDFDFDFDFDFDULL,
1622 0x00FDFDFDFDFDFDFDULL
1623 },
1624 {
1625 0x00000000000000FDULL,
1626 0x000000000000FDFDULL,
1627 0x0000000000FDFDFDULL,
1628 0x00000000FDFDFDFDULL,
1629 0x000000FDFDFDFDFDULL,
1630 0x0000FDFDFDFDFDFDULL,
1631 0x00FDFDFDFDFDFDFDULL,
1632 0xFDFDFDFDFDFDFDFDULL
1633 },
1634 {
1635 0x000000000000FDFDULL,
1636 0x0000000000FDFDFDULL,
1637 0x00000000FDFDFDFDULL,
1638 0x000000FDFDFDFDFDULL,
1639 0x0000FDFDFDFDFDFDULL,
1640 0x00FDFDFDFDFDFDFDULL,
1641 0xFDFDFDFDFDFDFDFDULL,
1642 0xFDFDFDFDFDFDFDFDULL
1643 },
1644 {
1645 0x0000000000FDFDFDULL,
1646 0x00000000FDFDFDFDULL,
1647 0x000000FDFDFDFDFDULL,
1648 0x0000FDFDFDFDFDFDULL,
1649 0x00FDFDFDFDFDFDFDULL,
1650 0xFDFDFDFDFDFDFDFDULL,
1651 0xFDFDFDFDFDFDFDFDULL,
1652 0xFDFDFDFDFDFDFDFDULL
1653 },
1654 {
1655 0x00000000FDFDFDFDULL,
1656 0x000000FDFDFDFDFDULL,
1657 0x0000FDFDFDFDFDFDULL,
1658 0x00FDFDFDFDFDFDFDULL,
1659 0xFDFDFDFDFDFDFDFDULL,
1660 0xFDFDFDFDFDFDFDFDULL,
1661 0xFDFDFDFDFDFDFDFDULL,
1662 0xFDFDFDFDFDFDFDFDULL
1663 },
1664 {
1665 0x000000FDFDFDFDFDULL,
1666 0x0000FDFDFDFDFDFDULL,
1667 0x00FDFDFDFDFDFDFDULL,
1668 0xFDFDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL,
1672 0xFDFDFDFDFDFDFDFDULL
1673 },
1674 {
1675 0x0000FDFDFDFDFDFDULL,
1676 0x00FDFDFDFDFDFDFDULL,
1677 0xFDFDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL,
1682 0xFDFDFDFDFDFDFDFDULL
1683 },
1684 {
1685 0x00FDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL,
1692 0xFDFDFDFDFDFDFDFDULL
1693 },
1694 {
1695 0xFDFDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL,
1702 0xFDFDFDFDFDFDFDFDULL
1703 }
1704 }
1705 };
1706
1707 int32_t black_opening_count=0;
1708 int32_t black_opening_x,black_opening_y;
1709 int32_t black_opening_shape;
1710
1711 791 int32_t choose_opening_shape()
1712 {
1713 // First, count how many bits are set
1714 791 int32_t numBits=0;
1715 int32_t bitCounter;
1716
1717
2/2
✓ Branch 0 taken 3955 times.
✓ Branch 1 taken 791 times.
4746 for(int32_t i=0; i<bosMAX; i++)
1718 {
1719
2/2
✓ Branch 0 taken 2948 times.
✓ Branch 1 taken 1007 times.
3955 if(COOLSCROLL&(1<<i))
1720 1007 numBits++;
1721 3955 }
1722
1723 // Shouldn't happen...
1724
1/2
✓ Branch 0 taken 791 times.
✗ Branch 1 not taken.
791 if(numBits==0)
1725 return bosCIRCLE;
1726
1727 // Pick a bit
1728 791 bitCounter=zc_rand()%numBits+1;
1729
1730
2/2
✓ Branch 0 taken 1003 times.
✓ Branch 1 taken 26 times.
1029 for(int32_t i=0; i<bosMAX; i++)
1731 {
1732 // If this bit is set, decrement the bit counter
1733
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 921 times.
1003 if(COOLSCROLL&(1<<i))
1734 921 bitCounter--;
1735
1736 // When the counter hits 0, return a value based on
1737 // which bit it stopped on.
1738 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1739
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 238 times.
1003 if(bitCounter==0)
1740 765 return i;
1741 238 }
1742
1743 // Shouldn't be necessary, but the compiler might complain, at least
1744 26 return bosCIRCLE;
1745 791 }
1746
1747 216 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1748 {
1749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1750
1751 216 int32_t w=256, h=224;
1752 216 int32_t blockrows=28, blockcolumns=32;
1753 216 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1754
1755
2/2
✓ Branch 0 taken 6048 times.
✓ Branch 1 taken 216 times.
6264 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1756 {
1757
2/2
✓ Branch 0 taken 193536 times.
✓ Branch 1 taken 6048 times.
199584 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1758 {
1759
2/2
✓ Branch 0 taken 103944 times.
✓ Branch 1 taken 89592 times.
193536 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1760 193536 }
1761 6048 }
1762
1763 216 black_opening_count = 66;
1764 216 black_opening_x = x;
1765 216 black_opening_y = y;
1766 216 lensclk = 0;
1767 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1768
1769
1770
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(black_opening_shape == bosFADEBLACK)
1771 {
1772 refreshTints();
1773 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1774 }
1775
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(wait)
1776 {
1777 FFCore.warpScriptCheck();
1778 for(int32_t i=0; i<66; i++)
1779 {
1780 draw_screen(tmpscr);
1781 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1782 advanceframe(true);
1783
1784 if(Quit)
1785 {
1786 break;
1787 }
1788 }
1789 }
1790 216 }
1791
1792 575 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1793 {
1794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1795
1796 575 int32_t w=256, h=224;
1797 575 int32_t blockrows=28, blockcolumns=32;
1798 575 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1799
1800
2/2
✓ Branch 0 taken 16100 times.
✓ Branch 1 taken 575 times.
16675 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1801 {
1802
2/2
✓ Branch 0 taken 515200 times.
✓ Branch 1 taken 16100 times.
531300 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1803 {
1804
2/2
✓ Branch 0 taken 241603 times.
✓ Branch 1 taken 273597 times.
515200 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1805 515200 }
1806 16100 }
1807
1808 575 black_opening_count = -66;
1809 575 black_opening_x = x;
1810 575 black_opening_y = y;
1811 575 lensclk = 0;
1812
1/2
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
575 if(black_opening_shape == bosFADEBLACK)
1813 {
1814 refreshTints();
1815 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1816 }
1817
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 465 times.
575 if(wait)
1818 {
1819 465 FFCore.warpScriptCheck();
1820
2/2
✓ Branch 0 taken 465 times.
✓ Branch 1 taken 30690 times.
31155 for(int32_t i=0; i<66; i++)
1821 {
1822 30690 draw_screen(tmpscr);
1823 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1824 30690 advanceframe(true);
1825
1826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30690 times.
30690 if(Quit)
1827 {
1828 break;
1829 }
1830 30690 }
1831 465 }
1832 575 }
1833
1834 52206 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1835 {
1836 52206 clear_to_color(tmp_scr,BLACK);
1837 52206 int32_t w=256, h=224;
1838
1839
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 49038 times.
52206 switch(black_opening_shape)
1840 {
1841 case bosOVAL:
1842 {
1843 858 double new_w=(w/2)+abs(w/2-x);
1844 858 double new_h=(h/2)+abs(h/2-y);
1845 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1846 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1847 858 break;
1848 }
1849
1850 case bosTRIANGLE:
1851 {
1852 660 double new_w=(w/2)+abs(w/2-x);
1853 660 double new_h=(h/2)+abs(h/2-y);
1854 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1855 660 double P2= (PI/2);
1856 660 double P23=(2*PI/3);
1857 660 double P43=(4*PI/3);
1858 660 double Pa= (-4*PI*a/(3*max_a));
1859 660 double angle=P2+Pa;
1860 660 double a0=angle;
1861 660 double a2=angle+P23;
1862 660 double a4=angle+P43;
1863 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1864 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1865 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1866 0);
1867 660 break;
1868 }
1869
1870 case bosSMAS:
1871 {
1872
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1873
1874
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1875 {
1876
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1877 {
1878 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1879
1880
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1881 {
1882 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1883
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1884 11827200 [linerow];
1885 11827200 ++triangleline;
1886
1887
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1888 {
1889 1478400 }
1890 11827200 }
1891 369600 }
1892 46200 }
1893
1894 1650 break;
1895 }
1896
1897 case bosFADEBLACK:
1898 {
1899 if(black_opening_count<0)
1900 {
1901 black_fade(zc_min(-black_opening_count,63));
1902 }
1903 else if(black_opening_count>0)
1904 {
1905 black_fade(63-zc_max(black_opening_count-3,0));
1906 }
1907 else black_fade(0);
1908 return; //no blitting from tmp_scr!
1909 }
1910
1911 49038 case bosCIRCLE:
1912 default:
1913 {
1914 49038 double new_w=(w/2)+abs(w/2-x);
1915 49038 double new_h=(h/2)+abs(h/2-y);
1916 49038 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1917 //circlefill(tmp_scr,x,y,a<<3,0);
1918 49038 circlefill(tmp_scr,x,y,r,0);
1919 49038 break;
1920 }
1921 }
1922
1923 52206 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1924 52206 }
1925
1926
1927 void black_fade(int32_t fadeamnt)
1928 {
1929 for(int32_t i=0; i < 0xEF; i++)
1930 {
1931 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1932 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1933 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1934 }
1935
1936 refreshpal = true;
1937 }
1938
1939 //----------------------------------------------------------------
1940
1941 15952490 bool item_disabled(int32_t item) //is this item disabled?
1942 {
1943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15952490 times.
15952490 return (item>=0 && game->items_off[item] != 0);
1944 }
1945
1946 5426600 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1947 {
1948
2/2
✓ Branch 0 taken 57842 times.
✓ Branch 1 taken 5368758 times.
5426600 if(current_item(item_type, true) >=item)
1949 {
1950 57842 return true;
1951 }
1952
1953 5368758 return false;
1954 5426600 }
1955
1956 22449319 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1957 {
1958
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4086346 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2439977 times.
✓ Branch 6 taken 12012783 times.
✓ Branch 7 taken 3882589 times.
✓ Branch 8 taken 27624 times.
22449319 switch(item_type)
1959 {
1960 case itype_bomb:
1961 case itype_sbomb:
1962 {
1963 int32_t itemid = getItemID(itemsbuf, item_type, it);
1964
1965 if(itemid == -1)
1966 return false;
1967
1968 return (game->get_item(itemid));
1969 }
1970
1971 case itype_clock:
1972 {
1973 4086346 int32_t itemid = getItemID(itemsbuf, item_type, it);
1974
1975
2/4
✓ Branch 0 taken 4086346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4086346 times.
✗ Branch 3 not taken.
4086346 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1976 return (game->get_item(itemid));
1977 4086346 return Hero.getClock()?1:0;
1978 }
1979
1980 case itype_key:
1981 return (game->get_keys()>0);
1982
1983 case itype_magiccontainer:
1984 return (game->get_maxmagic()>=game->get_mp_per_block());
1985
1986 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1987 {
1988
1/3
✓ Branch 0 taken 2439977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2439977 switch(it)
1989 {
1990 case -2:
1991 {
1992 for(int32_t i=0; i<MAXLEVELS; i++)
1993 {
1994 if(game->lvlitems[i]&liTRIFORCE)
1995 {
1996 return true;
1997 }
1998 }
1999
2000 return false;
2001 }
2002
2003 case -1:
2004 return (game->lvlitems[dlevel]&liTRIFORCE);
2005
2006 default:
2007
2/4
✓ Branch 0 taken 2439977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2439977 times.
2439977 if(it>=0&&it<MAXLEVELS)
2008 {
2009 2439977 return (game->lvlitems[it]&liTRIFORCE);
2010 }
2011
2012 break;
2013 }
2014
2015 return 0;
2016 }
2017
2018 case itype_map: //it: -2=any, -1=current level, other=that level
2019 {
2020
1/3
✓ Branch 0 taken 12012783 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12012783 switch(it)
2021 {
2022 case -2:
2023 {
2024 for(int32_t i=0; i<MAXLEVELS; i++)
2025 {
2026 if(game->lvlitems[i]&liMAP)
2027 {
2028 return true;
2029 }
2030 }
2031
2032 return false;
2033 }
2034
2035 case -1:
2036 return (game->lvlitems[dlevel]&liMAP)!=0;
2037
2038 default:
2039
2/4
✓ Branch 0 taken 12012783 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12012783 times.
12012783 if(it>=0&&it<MAXLEVELS)
2040 {
2041 12012783 return (game->lvlitems[it]&liMAP)!=0;
2042 }
2043
2044 break;
2045 }
2046
2047 return 0;
2048 }
2049
2050 case itype_compass: //it: -2=any, -1=current level, other=that level
2051 {
2052
1/3
✓ Branch 0 taken 3882589 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3882589 switch(it)
2053 {
2054 case -2:
2055 {
2056 for(int32_t i=0; i<MAXLEVELS; i++)
2057 {
2058 if(game->lvlitems[i]&liCOMPASS)
2059 {
2060 return true;
2061 }
2062 }
2063
2064 return false;
2065 }
2066
2067 case -1:
2068 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2069
2070 default:
2071
2/4
✓ Branch 0 taken 3882589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3882589 times.
✗ Branch 3 not taken.
3882589 if(it>=0&&it<MAXLEVELS)
2072 {
2073 3882589 return (game->lvlitems[it]&liCOMPASS)!=0;
2074 }
2075
2076 break;
2077 }
2078 return 0;
2079 }
2080
2081 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2082 {
2083
1/3
✓ Branch 0 taken 27624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
27624 switch(it)
2084 {
2085 case -2:
2086 {
2087 for(int32_t i=0; i<MAXLEVELS; i++)
2088 {
2089 if(game->lvlitems[i]&liBOSSKEY)
2090 {
2091 return true;
2092 }
2093 }
2094
2095 return false;
2096 }
2097
2098 case -1:
2099 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2100
2101 default:
2102
2/4
✓ Branch 0 taken 27624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27624 times.
27624 if(it>=0&&it<MAXLEVELS)
2103 {
2104 27624 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2105 }
2106 break;
2107 }
2108 return 0;
2109 }
2110
2111 default:
2112 //it=(1<<(it-1));
2113 /*if (item_type>=itype_max)
2114 {
2115 system_pal();
2116 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2117 game_pal();
2118
2119 return false;
2120 }*/
2121 int32_t itemid = getItemID(itemsbuf, item_type, it);
2122
2123 if(itemid == -1)
2124 return false;
2125
2126 return game->get_item(itemid);
2127 }
2128 22449319 }
2129
2130
2131 69865212 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2132 {
2133
9/9
✓ Branch 0 taken 4086346 times.
✓ Branch 1 taken 37174444 times.
✓ Branch 2 taken 4086346 times.
✓ Branch 3 taken 4086346 times.
✓ Branch 4 taken 4086346 times.
✓ Branch 5 taken 4086346 times.
✓ Branch 6 taken 4086346 times.
✓ Branch 7 taken 4086346 times.
✓ Branch 8 taken 4086346 times.
69865212 switch(item_type)
2134 {
2135 case itype_clock:
2136 {
2137 4086346 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2138
2139
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4086346 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4086346 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2140 return itemsbuf[maxid].fam_type;
2141
2142 4086346 return has_item(itype_clock,1) ? 1 : 0;
2143 }
2144
2145 case itype_key:
2146 4086346 return game->get_keys();
2147
2148 case itype_lkey:
2149 4086346 return game->lvlkeys[get_dlevel()];
2150
2151 case itype_magiccontainer:
2152 4086346 return game->get_maxmagic()/game->get_mp_per_block();
2153
2154 case itype_triforcepiece:
2155 {
2156 4086346 int32_t count=0;
2157
2158
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2159 {
2160 2092209152 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2161 2092209152 }
2162
2163 4086346 return count;
2164 }
2165
2166 case itype_map:
2167 {
2168 4086346 int32_t count=0;
2169
2170
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2171 {
2172 2092209152 count+=(game->lvlitems[i]&liMAP)?1:0;
2173 2092209152 }
2174
2175 4086346 return count;
2176 }
2177
2178 case itype_compass:
2179 {
2180 4086346 int32_t count=0;
2181
2182
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2183 {
2184 2092209152 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2185 2092209152 }
2186
2187 4086346 return count;
2188 }
2189
2190 case itype_bosskey:
2191 {
2192 4086346 int32_t count=0;
2193
2194
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2195 {
2196 2092209152 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2197 2092209152 }
2198
2199 4086346 return count;
2200 }
2201
2202 default:
2203 37174444 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2204
2205
2/2
✓ Branch 0 taken 6971052 times.
✓ Branch 1 taken 30203392 times.
37174444 if(maxid == -1)
2206 30203392 return 0;
2207
2208 6971052 return itemsbuf[maxid].fam_type;
2209 }
2210 69865212 }
2211
2212 64438612 int32_t current_item(int32_t item_type) //item currently being used
2213 {
2214 64438612 return current_item(item_type, true);
2215 }
2216
2217 29 std::map<int32_t, int32_t> itemcache;
2218
2219 // Not actually used by anything at the moment...
2220 void removeFromItemCache(int32_t itemid)
2221 {
2222 itemcache.erase(itemid);
2223 }
2224
2225 19096 void flushItemCache()
2226 {
2227 19096 itemcache.clear();
2228
2229 //also fix the active subscreen if items were deleted -DD
2230
1/2
✓ Branch 0 taken 19096 times.
✗ Branch 1 not taken.
19096 if(game != NULL)
2231 {
2232 19096 verifyBothWeapons();
2233 19096 load_Sitems(&QMisc);
2234 19096 }
2235 19096 }
2236
2237 // This is used often, so it should be as direct as possible.
2238 2281827242 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2239 {
2240
2/2
✓ Branch 0 taken 2233022885 times.
✓ Branch 1 taken 48804357 times.
2281827242 if(jinx_check)
2241 {
2242
4/4
✓ Branch 0 taken 31164925 times.
✓ Branch 1 taken 17639432 times.
✓ Branch 2 taken 27758483 times.
✓ Branch 3 taken 3406442 times.
48804357 if(!(HeroSwordClk() || HeroItemClk()))
2243 27758483 jinx_check = false; //not jinxed
2244 48804357 }
2245
4/4
✓ Branch 0 taken 2262423702 times.
✓ Branch 1 taken 19403540 times.
✓ Branch 2 taken 20897290 times.
✓ Branch 3 taken 2241526412 times.
2281827242 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2246 {
2247 2241526412 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2248
2249
2/2
✓ Branch 0 taken 2231777900 times.
✓ Branch 1 taken 9748512 times.
2241526412 if(res != itemcache.end())
2250 2231777900 return res->second;
2251 9748512 }
2252
2253 50049342 int32_t result = -1;
2254 50049342 int32_t highestlevel = -1;
2255
2256
2/2
✓ Branch 0 taken 12812631552 times.
✓ Branch 1 taken 50049342 times.
12862680894 for(int32_t i=0; i<MAXITEMS; i++)
2257 {
2258
5/6
✓ Branch 0 taken 1030627526 times.
✓ Branch 1 taken 11782004026 times.
✓ Branch 2 taken 15409861 times.
✓ Branch 3 taken 1015217665 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15409861 times.
12812631552 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2259 {
2260
4/4
✓ Branch 0 taken 4655389 times.
✓ Branch 1 taken 10754472 times.
✓ Branch 2 taken 1195206 times.
✓ Branch 3 taken 14214655 times.
15409861 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2261 {
2262 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2263
2/2
✓ Branch 0 taken 14214535 times.
✓ Branch 1 taken 120 times.
14214655 if(!checkmagiccost(i))
2264 {
2265
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 108 times.
120 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2266 12 }
2267 14214547 }
2268
6/6
✓ Branch 0 taken 13234243 times.
✓ Branch 1 taken 2175510 times.
✓ Branch 2 taken 229100 times.
✓ Branch 3 taken 1946410 times.
✓ Branch 4 taken 1458492 times.
✓ Branch 5 taken 717018 times.
15409753 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2269 {
2270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717018 times.
717018 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2271 717018 continue;
2272 }
2273
2274
2/2
✓ Branch 0 taken 223586 times.
✓ Branch 1 taken 14469149 times.
14692735 if(itemsbuf[i].fam_type >= highestlevel)
2275 {
2276 14469149 highestlevel = itemsbuf[i].fam_type;
2277 14469149 result=i;
2278 14469149 }
2279 14692735 }
2280 12811914426 }
2281
2282
2/2
✓ Branch 0 taken 21045874 times.
✓ Branch 1 taken 29003468 times.
50049342 if(!jinx_check) //Can't cache jinx_check results
2283 29003468 itemcache[itemtype] = result;
2284 50049342 return result;
2285 2281827242 }
2286
2287 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2288 2261061951 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2289 {
2290 2261061951 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2291
2/2
✓ Branch 0 taken 28039066 times.
✓ Branch 1 taken 2233022885 times.
2261061951 if(!jinx_check) //If not already a jinx-immune-only check...
2292 {
2293 //And the player IS jinxed...
2294
4/4
✓ Branch 0 taken 2215614958 times.
✓ Branch 1 taken 17407927 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 2212257594 times.
2233022885 if(HeroSwordClk() || HeroItemClk())
2295 {
2296 //Then do a jinx-immune-only check here
2297 20765291 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2298 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2299 //Should NOT need a compat rule, as this should always return -1 in old quests.
2300
2/2
✓ Branch 0 taken 974915 times.
✓ Branch 1 taken 19790376 times.
20765291 if(ret2 > -1) return ret2;
2301 19790376 }
2302 2232047970 }
2303 2260087036 return ret;
2304 2261061951 }
2305 14776608 int32_t current_item_power(int32_t itemtype)
2306 {
2307 14776608 int32_t result = current_item_id(itemtype,true);
2308
2/2
✓ Branch 0 taken 11445380 times.
✓ Branch 1 taken 3331228 times.
14776608 return (result<0) ? 0 : itemsbuf[result].power;
2309 }
2310
2311 7 int32_t heart_container_id()
2312 {
2313
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2314 {
2315
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2316 {
2317 7 return i;
2318 }
2319 196 }
2320 return -1;
2321 7 }
2322
2323 4086346 int32_t item_tile_mod()
2324 {
2325 4086346 int32_t tile=0;
2326
2327
2/2
✓ Branch 0 taken 975760 times.
✓ Branch 1 taken 3110586 times.
4086346 if(game->get_bombs())
2328 {
2329 3110586 int32_t itemid = current_item_id(itype_bomb,false);
2330
3/4
✓ Branch 0 taken 3029527 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3029527 times.
3110586 if(itemid > -1 && checkbunny(itemid))
2331 3029527 tile+=itemsbuf[itemid].ltm;
2332 3110586 }
2333
2334
2/2
✓ Branch 0 taken 3032663 times.
✓ Branch 1 taken 1053683 times.
4086346 if(game->get_sbombs())
2335 {
2336 1053683 int32_t itemid = current_item_id(itype_sbomb,false);
2337
3/4
✓ Branch 0 taken 1052255 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1052255 times.
1053683 if(itemid > -1 && checkbunny(itemid))
2338 1052255 tile+=itemsbuf[itemid].ltm;
2339 1053683 }
2340
2341
2/2
✓ Branch 0 taken 3998396 times.
✓ Branch 1 taken 87950 times.
4086346 if(current_item(itype_clock))
2342 {
2343 87950 int32_t itemid =
2344
1/2
✓ Branch 0 taken 87950 times.
✗ Branch 1 not taken.
87950 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2345 ? iClock
2346 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2347
2/4
✓ Branch 0 taken 87950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 87950 times.
87950 if(itemid > -1 && checkbunny(itemid))
2348 87950 tile+=itemsbuf[itemid].ltm;
2349 87950 }
2350
2351
2/2
✓ Branch 0 taken 3438526 times.
✓ Branch 1 taken 647820 times.
4086346 if(current_item(itype_key))
2352 {
2353 647820 int32_t itemid =
2354
1/2
✓ Branch 0 taken 647820 times.
✗ Branch 1 not taken.
647820 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2355 ? iKey
2356 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2357
2/4
✓ Branch 0 taken 647820 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 647820 times.
647820 if(itemid > -1 && checkbunny(itemid))
2358 647820 tile+=itemsbuf[itemid].ltm;
2359 647820 }
2360
2361
2/2
✓ Branch 0 taken 3927093 times.
✓ Branch 1 taken 159253 times.
4086346 if(current_item(itype_lkey))
2362 {
2363 159253 int32_t itemid =
2364
2/2
✓ Branch 0 taken 158343 times.
✓ Branch 1 taken 910 times.
159253 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2365 ? iLevelKey
2366 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2367
2/4
✓ Branch 0 taken 159253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159253 times.
159253 if(itemid > -1 && checkbunny(itemid))
2368 159253 tile+=itemsbuf[itemid].ltm;
2369 159253 }
2370
2371
2/2
✓ Branch 0 taken 886117 times.
✓ Branch 1 taken 3200229 times.
4086346 if(current_item(itype_map))
2372 {
2373 3200229 int32_t itemid =
2374
2/2
✓ Branch 0 taken 3199443 times.
✓ Branch 1 taken 786 times.
3200229 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2375 ? iMap
2376 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2377
2/4
✓ Branch 0 taken 3200229 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3200229 times.
3200229 if(itemid > -1 && checkbunny(itemid))
2378 3200229 tile+=itemsbuf[itemid].ltm;
2379 3200229 }
2380
2381
2/2
✓ Branch 0 taken 807819 times.
✓ Branch 1 taken 3278527 times.
4086346 if(current_item(itype_compass))
2382 {
2383 3278527 int32_t itemid =
2384
2/2
✓ Branch 0 taken 3197468 times.
✓ Branch 1 taken 81059 times.
3278527 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2385 ? iCompass
2386 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2387
2/4
✓ Branch 0 taken 3278527 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3278527 times.
3278527 if(itemid > -1 && checkbunny(itemid))
2388 3278527 tile+=itemsbuf[itemid].ltm;
2389 3278527 }
2390
2391
2/2
✓ Branch 0 taken 2275984 times.
✓ Branch 1 taken 1810362 times.
4086346 if(current_item(itype_bosskey))
2392 {
2393 1810362 int32_t itemid =
2394
1/2
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
1810362 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2395 ? iBossKey
2396 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2397
2/4
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1810362 times.
1810362 if(itemid > -1 && checkbunny(itemid))
2398 1810362 tile+=itemsbuf[itemid].ltm;
2399 1810362 }
2400
2401
2/2
✓ Branch 0 taken 2141126 times.
✓ Branch 1 taken 1945220 times.
4086346 if(current_item(itype_magiccontainer))
2402 {
2403 1945220 int32_t itemid =
2404
2/2
✓ Branch 0 taken 1852005 times.
✓ Branch 1 taken 93215 times.
1945220 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2405 ? iMagicC
2406 93215 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2407
3/4
✓ Branch 0 taken 1945220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 1943350 times.
1945220 if(itemid > -1 && checkbunny(itemid))
2408 1943350 tile+=itemsbuf[itemid].ltm;
2409 1945220 }
2410
2411
2/2
✓ Branch 0 taken 1118041 times.
✓ Branch 1 taken 2968305 times.
4086346 if(current_item(itype_triforcepiece))
2412 {
2413 2968305 int32_t itemid =
2414
1/2
✓ Branch 0 taken 2968305 times.
✗ Branch 1 not taken.
2968305 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2415 ? iTriforce
2416 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2417
2/4
✓ Branch 0 taken 2968305 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2968305 times.
2968305 if(itemid > -1 && checkbunny(itemid))
2418 2968305 tile+=itemsbuf[itemid].ltm;
2419 2968305 }
2420
2421
2/2
✓ Branch 0 taken 4086346 times.
✓ Branch 1 taken 2092209152 times.
2096295498 for(int32_t i=0; i<itype_max; i++)
2422 {
2423
2/2
✓ Branch 0 taken 2035907072 times.
✓ Branch 1 taken 56302080 times.
2092209152 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2424 {
2425
2/2
✓ Branch 0 taken 1099650 times.
✓ Branch 1 taken 55202430 times.
56302080 switch(i)
2426 {
2427 case itype_bomb:
2428 case itype_sbomb:
2429 case itype_clock:
2430 case itype_key:
2431 case itype_lkey:
2432 case itype_map:
2433 case itype_compass:
2434 case itype_bosskey:
2435 case itype_magiccontainer:
2436 case itype_triforcepiece:
2437 1099650 continue; //already handled
2438 }
2439 55202430 }
2440 2091109502 int32_t itemid = current_item_id(i,false);
2441
2/2
✓ Branch 0 taken 2087023156 times.
✓ Branch 1 taken 4086346 times.
2091109502 if(i == itype_shield)
2442 4086346 itemid = getCurrentShield(false);
2443
2444
4/4
✓ Branch 0 taken 59139201 times.
✓ Branch 1 taken 2031970301 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 59038220 times.
2091109502 if(itemid < 0 || !checkbunny(itemid))
2445 2032071282 continue;
2446
2447 59038220 itemdata const& itm = itemsbuf[itemid];
2448
2449
2/2
✓ Branch 0 taken 55529396 times.
✓ Branch 1 taken 3508824 times.
59038220 switch(itm.family)
2450 {
2451 case itype_shield:
2452
1/2
✓ Branch 0 taken 3508824 times.
✗ Branch 1 not taken.
3508824 if(itm.flags & ITEM_FLAG9) //active shield
2453 {
2454 if(!usingActiveShield(itemid))
2455 {
2456 tile+=itm.misc6; //'Inactive PTM'
2457 continue;
2458 }
2459 }
2460 3508824 break;
2461 }
2462
2463 59038220 tile+=itm.ltm;
2464 59038220 }
2465
2466 4086346 return tile;
2467 }
2468
2469 4086346 int32_t bunny_tile_mod()
2470 {
2471
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 4084476 times.
4086346 if(Hero.BunnyClock())
2472 {
2473 1870 return game->get_bunny_ltm();
2474 }
2475 4084476 return 0;
2476 4086346 }
2477
2478 // Hints are drawn on a separate layer to combo reveals.
2479 16332 void draw_lens_under(BITMAP *dest, bool layer)
2480 {
2481 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2482 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2483 //Lens flag 3: Don't show armos/chest/dive items
2484 //Lens flag 4: Show Raft Paths
2485 //Lens flag 5: Show Invisible Enemies
2486
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2487
2488 16332 int32_t strike_hint_table[11]=
2489 {
2490 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2491 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2492 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2493 };
2494
2495 // int32_t page = tmpscr->cpage;
2496 {
2497 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2498 // int32_t temptimer=0;
2499 16332 int32_t tempitem, tempweapon=0;
2500 16332 strike_hint=strike_hint_table[strike_hint_counter];
2501
2502
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2503 {
2504 492 strike_hint_timer=0;
2505 492 strike_hint_counter=((strike_hint_counter+1)%11);
2506 492 }
2507
2508 16332 ++strike_hint_timer;
2509
2510
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2511 {
2512 2874432 int32_t x = (i & 15) << 4;
2513 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2514 2874432 int32_t tempitemx=-16, tempitemy=-16;
2515 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2516
2517
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2518 {
2519 5748864 int32_t checkflag=0;
2520
2521
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2522 {
2523 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2524 2874432 }
2525 else
2526 {
2527 2874432 checkflag=tmpscr->sflag[i];
2528 }
2529
2530
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2531 {
2532
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2533 {
2534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2535 906 }
2536 else
2537 {
2538 192 checkflag = strike_hint;
2539 }
2540 1098 }
2541
2542
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2543 {
2544 case 0:
2545 case mfZELDA:
2546 case mfPUSHED:
2547 case mfENEMY0:
2548 case mfENEMY1:
2549 case mfENEMY2:
2550 case mfENEMY3:
2551 case mfENEMY4:
2552 case mfENEMY5:
2553 case mfENEMY6:
2554 case mfENEMY7:
2555 case mfENEMY8:
2556 case mfENEMY9:
2557 case mfSINGLE:
2558 case mfSINGLE16:
2559 case mfNOENEMY:
2560 case mfTRAP_H:
2561 case mfTRAP_V:
2562 case mfTRAP_4:
2563 case mfTRAP_LR:
2564 case mfTRAP_UD:
2565 case mfNOGROUNDENEMY:
2566 case mfNOBLOCKS:
2567 case mfSCRIPT1:
2568 case mfSCRIPT2:
2569 case mfSCRIPT3:
2570 case mfSCRIPT4:
2571 case mfSCRIPT5:
2572 case mfSCRIPT6:
2573 case mfSCRIPT7:
2574 case mfSCRIPT8:
2575 case mfSCRIPT9:
2576 case mfSCRIPT10:
2577 case mfSCRIPT11:
2578 case mfSCRIPT12:
2579 case mfSCRIPT13:
2580 case mfSCRIPT14:
2581 case mfSCRIPT15:
2582 case mfSCRIPT16:
2583 case mfSCRIPT17:
2584 case mfSCRIPT18:
2585 case mfSCRIPT19:
2586 case mfSCRIPT20:
2587 case mfPITHOLE:
2588 case mfPITFALLFLOOR:
2589 case mfLAVA:
2590 case mfICE:
2591 case mfICEDAMAGE:
2592 case mfDAMAGE1:
2593 case mfDAMAGE2:
2594 case mfDAMAGE4:
2595 case mfDAMAGE8:
2596 case mfDAMAGE16:
2597 case mfDAMAGE32:
2598 case mfFREEZEALL:
2599 case mfFREZEALLANSFFCS:
2600 case mfFREEZEFFCSOLY:
2601 case mfSCRITPTW1TRIG:
2602 case mfSCRITPTW2TRIG:
2603 case mfSCRITPTW3TRIG:
2604 case mfSCRITPTW4TRIG:
2605 case mfSCRITPTW5TRIG:
2606 case mfSCRITPTW6TRIG:
2607 case mfSCRITPTW7TRIG:
2608 case mfSCRITPTW8TRIG:
2609 case mfSCRITPTW9TRIG:
2610 case mfSCRITPTW10TRIG:
2611 case mfTROWEL:
2612 case mfTROWELNEXT:
2613 case mfTROWELSPECIALITEM:
2614 case mfSLASHPOT:
2615 case mfLIFTPOT:
2616 case mfLIFTORSLASH:
2617 case mfLIFTROCK:
2618 case mfLIFTROCKHEAVY:
2619 case mfDROPITEM:
2620 case mfSPECIALITEM:
2621 case mfDROPKEY:
2622 case mfDROPLKEY:
2623 case mfDROPCOMPASS:
2624 case mfDROPMAP:
2625 case mfDROPBOSSKEY:
2626 case mfSPAWNNPC:
2627 case mfSWITCHHOOK:
2628 case mfSIDEVIEWLADDER:
2629 case mfSIDEVIEWPLATFORM:
2630 case mfNOENEMYSPAWN:
2631 case mfENEMYALL:
2632 case mfNOMIRROR:
2633 case mfUNSAFEGROUND:
2634 case mf168:
2635 case mf169:
2636 case mf170:
2637 case mf171:
2638 case mf172:
2639 case mf173:
2640 case mf174:
2641 case mf175:
2642 case mf176:
2643 case mf177:
2644 case mf178:
2645 case mf179:
2646 case mf180:
2647 case mf181:
2648 case mf182:
2649 case mf183:
2650 case mf184:
2651 case mf185:
2652 case mf186:
2653 case mf187:
2654 case mf188:
2655 case mf189:
2656 case mf190:
2657 case mf191:
2658 case mf192:
2659 case mf193:
2660 case mf194:
2661 case mf195:
2662 case mf196:
2663 case mf197:
2664 case mf198:
2665 case mf199:
2666 case mf200:
2667 case mf201:
2668 case mf202:
2669 case mf203:
2670 case mf204:
2671 case mf205:
2672 case mf206:
2673 case mf207:
2674 case mf208:
2675 case mf209:
2676 case mf210:
2677 case mf211:
2678 case mf212:
2679 case mf213:
2680 case mf214:
2681 case mf215:
2682 case mf216:
2683 case mf217:
2684 case mf218:
2685 case mf219:
2686 case mf220:
2687 case mf221:
2688 case mf222:
2689 case mf223:
2690 case mf224:
2691 case mf225:
2692 case mf226:
2693 case mf227:
2694 case mf228:
2695 case mf229:
2696 case mf230:
2697 case mf231:
2698 case mf232:
2699 case mf233:
2700 case mf234:
2701 case mf235:
2702 case mf236:
2703 case mf237:
2704 case mf238:
2705 case mf239:
2706 case mf240:
2707 case mf241:
2708 case mf242:
2709 case mf243:
2710 case mf244:
2711 case mf245:
2712 case mf246:
2713 case mf247:
2714 case mf248:
2715 case mf249:
2716 case mf250:
2717 case mf251:
2718 case mf252:
2719 case mf253:
2720 case mf254:
2721 case mfEXTENDED:
2722 5706470 break;
2723
2724 case mfPUSHUD:
2725 case mfPUSHLR:
2726 case mfPUSH4:
2727 case mfPUSHU:
2728 case mfPUSHD:
2729 case mfPUSHL:
2730 case mfPUSHR:
2731 case mfPUSHUDNS:
2732 case mfPUSHLRNS:
2733 case mfPUSH4NS:
2734 case mfPUSHUNS:
2735 case mfPUSHDNS:
2736 case mfPUSHLNS:
2737 case mfPUSHRNS:
2738 case mfPUSHUDINS:
2739 case mfPUSHLRINS:
2740 case mfPUSH4INS:
2741 case mfPUSHUINS:
2742 case mfPUSHDINS:
2743 case mfPUSHLINS:
2744 case mfPUSHRINS:
2745
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2746
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2747 {
2748 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2749 }
2750
2751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2752
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2753 {
2754
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2755 {
2756
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2757 {
2758 case cPUSH_HEAVY:
2759 case cPUSH_HW:
2760 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2761 72 tempitemx=x, tempitemy=y;
2762
2763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2764 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2765
2766 72 break;
2767
2768 case cPUSH_HEAVY2:
2769 case cPUSH_HW2:
2770 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2771 63 tempitemx=x, tempitemy=y;
2772
2773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2774 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2775
2776 63 break;
2777 }
2778 1032 }
2779 2438 }
2780
2781 3148 break;
2782
2783 case mfWHISTLE:
2784
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2785 {
2786 tempitem=getItemID(itemsbuf,itype_whistle,1);
2787
2788 if(tempitem<0) break;
2789
2790 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2791 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2792 {
2793 tempitemx=x;
2794 tempitemy=y;
2795 }
2796
2797 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2798 }
2799
2800 2418 break;
2801
2802 //Why is this here?
2803 case mfFAIRY:
2804 case mfMAGICFAIRY:
2805 case mfALLFAIRY:
2806 if(hints)
2807 {
2808 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2809
2810 if(tempitem < 0) break;
2811
2812 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2813 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2814 {
2815 tempitemx=x;
2816 tempitemy=y;
2817 }
2818
2819 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2820 }
2821
2822 break;
2823
2824 case mfANYFIRE:
2825
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2826 {
2827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2828 252 }
2829 else
2830 {
2831 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2832
2833
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2834
2835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2836
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2837 {
2838 189 tempitemx=x;
2839 189 tempitemy=y;
2840 189 }
2841
2842 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2843 }
2844
2845 504 break;
2846
2847 case mfSTRONGFIRE:
2848 if(!hints)
2849 {
2850 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2851 }
2852 else
2853 {
2854 tempitem=getItemID(itemsbuf,itype_candle,2);
2855
2856 if(tempitem<0) break;
2857
2858 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2859 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2860 {
2861 tempitemx=x;
2862 tempitemy=y;
2863 }
2864
2865 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2866 }
2867
2868 break;
2869
2870 case mfMAGICFIRE:
2871 if(!hints)
2872 {
2873 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2874 }
2875 else
2876 {
2877 tempitem=getItemID(itemsbuf,itype_wand,1);
2878
2879 if(tempitem<0) break;
2880
2881 tempweapon=wFire;
2882
2883 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2884 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2885 {
2886 tempitemx=x;
2887 tempitemy=y;
2888 }
2889 else
2890 {
2891 tempweaponx=x;
2892 tempweapony=y;
2893 }
2894
2895 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2896 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2897 }
2898
2899 break;
2900
2901 case mfDIVINEFIRE:
2902 if(!hints)
2903 {
2904 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2905 }
2906 else
2907 {
2908 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2909
2910 if(tempitem<0) break;
2911
2912 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2913 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2914 {
2915 tempitemx=x;
2916 tempitemy=y;
2917 }
2918
2919 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2920 }
2921
2922 break;
2923
2924 case mfARROW:
2925
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2926 {
2927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2928 732 }
2929 else
2930 {
2931 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2932
2933
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2934
2935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2936
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2937 {
2938 61 tempitemx=x;
2939 61 tempitemy=y;
2940 61 }
2941
2942 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2943 }
2944
2945 814 break;
2946
2947 case mfSARROW:
2948 if(!hints)
2949 {
2950 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2951 }
2952 else
2953 {
2954 tempitem=getItemID(itemsbuf,itype_arrow,2);
2955
2956 if(tempitem<0) break;
2957
2958 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2959 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2960 {
2961 tempitemx=x;
2962 tempitemy=y;
2963 }
2964
2965 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2966 }
2967
2968 break;
2969
2970 case mfGARROW:
2971 if(!hints)
2972 {
2973 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2974 }
2975 else
2976 {
2977 tempitem=getItemID(itemsbuf,itype_arrow,3);
2978
2979 if(tempitem<0) break;
2980
2981 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2982 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2983 {
2984 tempitemx=x;
2985 tempitemy=y;
2986 }
2987
2988 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2989 }
2990
2991 break;
2992
2993 case mfBOMB:
2994
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
2995 {
2996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2997 16 }
2998 else
2999 {
3000 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3001 17 tempweapon = wLitBomb;
3002
3003 //if (tempitem<0) break;
3004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3005
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3006 {
3007 12 tempweaponx=x;
3008 12 tempweapony=y;
3009 12 }
3010
3011 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3012 }
3013
3014 33 break;
3015
3016 case mfSBOMB:
3017
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3018 {
3019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3020 48 }
3021 else
3022 {
3023 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3024 //if (tempitem<0) break;
3025 48 tempweapon = wLitSBomb;
3026
3027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3028
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3029 {
3030 36 tempweaponx=x;
3031 36 tempweapony=y;
3032 36 }
3033
3034 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3035 }
3036
3037 96 break;
3038
3039 case mfARMOS_SECRET:
3040
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3041 {
3042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3043 12 }
3044 24 break;
3045
3046 case mfBRANG:
3047
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3048 {
3049 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3050 }
3051 else
3052 {
3053 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3054
3055
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3056
3057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3058
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3059 {
3060 4 tempitemx=x;
3061 4 tempitemy=y;
3062 4 }
3063
3064 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3065 }
3066
3067 5 break;
3068
3069 case mfMBRANG:
3070 if(!hints)
3071 {
3072 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3073 }
3074 else
3075 {
3076 tempitem=getItemID(itemsbuf,itype_brang,2);
3077
3078 if(tempitem<0) break;
3079
3080 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3081 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3082 {
3083 tempitemx=x;
3084 tempitemy=y;
3085 }
3086
3087 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3088 }
3089
3090 break;
3091
3092 case mfFBRANG:
3093 if(!hints)
3094 {
3095 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3096 }
3097 else
3098 {
3099 tempitem=getItemID(itemsbuf,itype_brang,3);
3100
3101 if(tempitem<0) break;
3102
3103 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3104 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3105 {
3106 tempitemx=x;
3107 tempitemy=y;
3108 }
3109
3110 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3111 }
3112
3113 break;
3114
3115 case mfWANDMAGIC:
3116 if(!hints)
3117 {
3118 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3119 }
3120 else
3121 {
3122 tempitem=getItemID(itemsbuf,itype_wand,1);
3123
3124 if(tempitem<0) break;
3125
3126 tempweapon=itemsbuf[tempitem].wpn3;
3127
3128 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3129 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3130 {
3131 tempitemx=x;
3132 tempitemy=y;
3133 }
3134 else
3135 {
3136 tempweaponx=x;
3137 tempweapony=y;
3138 --lens_hint_weapon[wMagic][4];
3139
3140 if(lens_hint_weapon[wMagic][4]<-8)
3141 {
3142 lens_hint_weapon[wMagic][4]=8;
3143 }
3144 }
3145
3146 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3147 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3148 }
3149
3150 break;
3151
3152 case mfREFMAGIC:
3153
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3154 {
3155 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3156 }
3157 else
3158 {
3159 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3160
3161
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3162
3163 16 tempweapon=ewMagic;
3164
3165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3166
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3167 {
3168 13 tempitemx=x;
3169 13 tempitemy=y;
3170 13 }
3171 else
3172 {
3173 3 tempweaponx=x;
3174 3 tempweapony=y;
3175
3176
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3177 {
3178 1 --lens_hint_weapon[ewMagic][4];
3179 1 }
3180 else
3181 {
3182 2 ++lens_hint_weapon[ewMagic][4];
3183 }
3184
3185
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3186 {
3187 lens_hint_weapon[ewMagic][2]=up;
3188 }
3189
3190
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3191 {
3192 2 lens_hint_weapon[ewMagic][2]=down;
3193 2 }
3194 }
3195
3196 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3197 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3198 }
3199
3200 16 break;
3201
3202 case mfREFFIREBALL:
3203
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3204 {
3205 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3206 }
3207 else
3208 {
3209 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3210
3211
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3212
3213 16 tempweapon=ewFireball;
3214
3215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3216
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3217 {
3218 12 tempitemx=x;
3219 12 tempitemy=y;
3220 12 tempweaponx=x;
3221 12 tempweapony=y;
3222 12 ++lens_hint_weapon[ewFireball][3];
3223
3224
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3225 {
3226 1 lens_hint_weapon[ewFireball][3]=-8;
3227 1 lens_hint_weapon[ewFireball][4]=8;
3228 1 }
3229
3230
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3231 {
3232 8 ++lens_hint_weapon[ewFireball][4];
3233 8 }
3234 else
3235 {
3236 4 --lens_hint_weapon[ewFireball][4];
3237 }
3238 12 }
3239
3240 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3241 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3242 }
3243
3244 16 break;
3245
3246 case mfSWORD:
3247
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3248 {
3249 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3250 }
3251 else
3252 {
3253 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3254
3255
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3256
3257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3258
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3259 {
3260 5 tempitemx=x;
3261 5 tempitemy=y;
3262 5 }
3263
3264 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3265 }
3266
3267 7 break;
3268
3269 case mfWSWORD:
3270 if(!hints)
3271 {
3272 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3273 }
3274 else
3275 {
3276 tempitem=getItemID(itemsbuf,itype_sword,2);
3277
3278 if(tempitem<0) break;
3279
3280 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3281 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3282 {
3283 tempitemx=x;
3284 tempitemy=y;
3285 }
3286
3287 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3288 }
3289
3290 break;
3291
3292 case mfMSWORD:
3293 if(!hints)
3294 {
3295 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3296 }
3297 else
3298 {
3299 tempitem=getItemID(itemsbuf,itype_sword,3);
3300
3301 if(tempitem<0) break;
3302
3303 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3304 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3305 {
3306 tempitemx=x;
3307 tempitemy=y;
3308 }
3309
3310 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3311 }
3312
3313 break;
3314
3315 case mfXSWORD:
3316 if(!hints)
3317 {
3318 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3319 }
3320 else
3321 {
3322 tempitem=getItemID(itemsbuf,itype_sword,4);
3323
3324 if(tempitem<0) break;
3325
3326 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3327 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3328 {
3329 tempitemx=x;
3330 tempitemy=y;
3331 }
3332
3333 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3334 }
3335
3336 break;
3337
3338 case mfSWORDBEAM:
3339
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3340 {
3341 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3342 }
3343 else
3344 {
3345 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3346
3347
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3348
3349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3350
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3351 {
3352 11 tempitemx=x;
3353 11 tempitemy=y;
3354 11 }
3355
3356 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3357 }
3358
3359 16 break;
3360
3361 case mfWSWORDBEAM:
3362 if(!hints)
3363 {
3364 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3365 }
3366 else
3367 {
3368 tempitem=getItemID(itemsbuf,itype_sword,2);
3369
3370 if(tempitem<0) break;
3371
3372 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3373 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3374 {
3375 tempitemx=x;
3376 tempitemy=y;
3377 }
3378
3379 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3380 }
3381
3382 break;
3383
3384 case mfMSWORDBEAM:
3385 if(!hints)
3386 {
3387 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3388 }
3389 else
3390 {
3391 tempitem=getItemID(itemsbuf,itype_sword,3);
3392
3393 if(tempitem<0) break;
3394
3395 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3396 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3397 {
3398 tempitemx=x;
3399 tempitemy=y;
3400 }
3401
3402 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3403 }
3404
3405 break;
3406
3407 case mfXSWORDBEAM:
3408 if(!hints)
3409 {
3410 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3411 }
3412 else
3413 {
3414 tempitem=getItemID(itemsbuf,itype_sword,4);
3415
3416 if(tempitem<0) break;
3417
3418 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3419 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3420 {
3421 tempitemx=x;
3422 tempitemy=y;
3423 }
3424
3425 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3426 }
3427
3428 break;
3429
3430 case mfHOOKSHOT:
3431
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3432 {
3433 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3434 }
3435 else
3436 {
3437 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3438
3439
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3440
3441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3442
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3443 {
3444 12 tempitemx=x;
3445 12 tempitemy=y;
3446 12 }
3447
3448 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3449 }
3450
3451 17 break;
3452
3453 case mfWAND:
3454
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3455 {
3456 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3457 }
3458 else
3459 {
3460 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3461
3462
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3463
3464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3465
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3466 {
3467 28 tempitemx=x;
3468 28 tempitemy=y;
3469 28 }
3470
3471 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3472 }
3473
3474 35 break;
3475
3476 case mfHAMMER:
3477
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3478 {
3479 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3480 }
3481 else
3482 {
3483 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3484
3485
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3486
3487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3488
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3489 {
3490 13 tempitemx=x;
3491 13 tempitemy=y;
3492 13 }
3493
3494 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3495 }
3496
3497 17 break;
3498
3499 case mfARMOS_ITEM:
3500 case mfDIVE_ITEM:
3501
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3502 {
3503 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3504 2064 }
3505 2064 break;
3506
3507 case 16:
3508 case 17:
3509 case 18:
3510 case 19:
3511 case 20:
3512 case 21:
3513 case 22:
3514 case 23:
3515 case 24:
3516 case 25:
3517 case 26:
3518 case 27:
3519 case 28:
3520 case 29:
3521 case 30:
3522 case 31:
3523
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3525 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3526
3527 3618 break;
3528 case mfSECRETSNEXT:
3529 if(!hints)
3530 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3531 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3532
3533 break;
3534
3535 case mfSTRIKE:
3536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3537 {
3538 906 goto special;
3539 }
3540 else
3541 {
3542 break;
3543 }
3544
3545 28640 default: goto special;
3546
3547 special:
3548
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3549 {
3550
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3551 {
3552 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3553 4913 }
3554 6549 }
3555
3556 29546 break;
3557 }
3558 5748864 }
3559 2874432 }
3560
3561
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3562 {
3563
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3564 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3565
3566
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3567 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3568
3569
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3570 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3571
3572
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3573 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3574
3575
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3576 {
3577 43 showbombeddoor(dest, 0);
3578 43 }
3579
3580
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3581 {
3582 39 showbombeddoor(dest, 1);
3583 39 }
3584
3585
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3586 {
3587 showbombeddoor(dest, 2);
3588 }
3589
3590
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3591 {
3592 37 showbombeddoor(dest, 3);
3593 37 }
3594 8166 }
3595
3596
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3597 {
3598
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3599 {
3600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3601 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3602 1123 }
3603 else
3604 {
3605
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3606 {
3607 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3608 48 int32_t tempitemx=-16;
3609 48 int32_t tempitemy=-16;
3610
3611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3612
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3613 {
3614 24 tempitemx=tmpscr->stairx;
3615 24 tempitemy=tmpscr->stairy+playing_field_offset;
3616 24 }
3617
3618 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3619 48 }
3620 }
3621 2034 }
3622 }
3623 16332 }
3624
3625 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3626
3627 7997 void draw_lens_over()
3628 {
3629 // Oh, what the heck.
3630 static BITMAP *lens_scr = NULL;
3631 static int32_t last_width = -1;
3632 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3633
3634 // Only redraw the circle if the size has changed
3635
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3636 {
3637
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3638 {
3639 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3640 5 }
3641
3642 5 clear_to_color(lens_scr, BLACK);
3643 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3644 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3645 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3646 5 last_width=width;
3647 5 }
3648
3649 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3650 7997 }
3651
3652 //----------------------------------------------------------------
3653
3654 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3655 {
3656 //recreating a big bitmap every frame is highly sluggish.
3657
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3658 30701 clear_to_color(wavebuf, BLACK);
3659 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3660
3661 int32_t ofs;
3662 // int32_t amplitude=8;
3663 // int32_t wavelength=4;
3664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3665
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3666 30701 int32_t amp2=168;
3667
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3668 30701 int32_t i=frame%amp2;
3669
3670
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3671 {
3672
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3673 {
3674 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3675 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3676 }
3677 else
3678 {
3679 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3680 }
3681
3682
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3683 {
3684
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3685 {
3686 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3687 1320388608 }
3688 5157768 }
3689 5157768 }
3690 30701 }
3691
3692 2832 void draw_fuzzy(int32_t fuzz)
3693 // draws from right half of scrollbuf to framebuf
3694 {
3695 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3696 byte *start, *si, *di;
3697
3698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2832 times.
2832 if(fuzz<1)
3699 fuzz = 1;
3700
3701 2832 xstep = 128%fuzz;
3702
3703
2/2
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 2242 times.
2832 if(xstep > 0)
3704 2242 xstep = fuzz-xstep;
3705
3706 2832 ystep = 112%fuzz;
3707
3708
2/2
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 2006 times.
2832 if(ystep > 0)
3709 2006 ystep = fuzz-ystep;
3710
3711 2832 firsty = 1;
3712
3713
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 102188 times.
105020 for(y=0; y<224;)
3714 {
3715 102188 start = &(scrollbuf->line[y][256]);
3716
3717
4/4
✓ Branch 0 taken 100772 times.
✓ Branch 1 taken 635784 times.
✓ Branch 2 taken 634368 times.
✓ Branch 3 taken 102188 times.
736556 for(dy=0; dy<ystep && dy+y<224; dy++)
3718 {
3719 634368 si = start;
3720 634368 di = &(framebuf->line[y+dy][0]);
3721 634368 i = xstep;
3722 634368 firstx = 1;
3723
3724
2/2
✓ Branch 0 taken 162398208 times.
✓ Branch 1 taken 634368 times.
163032576 for(dx=0; dx<256; dx++)
3725 {
3726 162398208 *(di++) = *si;
3727
3728
2/2
✓ Branch 0 taken 136838464 times.
✓ Branch 1 taken 25559744 times.
162398208 if(++i >= fuzz)
3729 {
3730
2/2
✓ Branch 0 taken 24925376 times.
✓ Branch 1 taken 634368 times.
25559744 if(!firstx)
3731 24925376 si += fuzz;
3732 else
3733 {
3734 634368 si += fuzz-xstep;
3735 634368 firstx = 0;
3736 }
3737
3738 25559744 i = 0;
3739 25559744 }
3740 162398208 }
3741 634368 }
3742
3743
2/2
✓ Branch 0 taken 99356 times.
✓ Branch 1 taken 2832 times.
102188 if(!firsty)
3744 99356 y += fuzz;
3745 else
3746 {
3747 2832 y += ystep;
3748 2832 ystep = fuzz;
3749 2832 firsty = 0;
3750 }
3751 }
3752 2832 }
3753
3754 6510665 void updatescr(bool allowwavy)
3755 {
3756
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 6510636 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
6510665 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3757
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 6510636 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
6510665 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3758
3759
2/2
✓ Branch 0 taken 6484961 times.
✓ Branch 1 taken 25704 times.
6510665 if(toogam)
3760 {
3761 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3762 25704 }
3763
3764
1/2
✓ Branch 0 taken 6510665 times.
✗ Branch 1 not taken.
6510665 if(Showpal)
3765 dump_pal(framebuf);
3766
3767
2/2
✓ Branch 0 taken 6428643 times.
✓ Branch 1 taken 82022 times.
6510665 if(!Playing)
3768 82022 black_opening_count=0;
3769
3770
2/2
✓ Branch 0 taken 6472715 times.
✓ Branch 1 taken 37950 times.
6510665 if(black_opening_count<0) //shape is opening up
3771 {
3772 37950 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3773
3774
2/4
✓ Branch 0 taken 37950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37950 times.
37950 if(Advance||(!Paused))
3775 {
3776 37950 ++black_opening_count;
3777 37950 }
3778 37950 }
3779
2/2
✓ Branch 0 taken 6458459 times.
✓ Branch 1 taken 14256 times.
6472715 else if(black_opening_count>0) //shape is closing
3780 {
3781 14256 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3782
3783
2/4
✓ Branch 0 taken 14256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14256 times.
14256 if(Advance||(!Paused))
3784 {
3785 14256 --black_opening_count;
3786 14256 }
3787 14256 }
3788
3789
3/4
✓ Branch 0 taken 6459250 times.
✓ Branch 1 taken 51415 times.
✓ Branch 2 taken 6459250 times.
✗ Branch 3 not taken.
6510665 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3790 {
3791 black_opening_shape = bosCIRCLE;
3792 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3793 refreshTints();
3794 refreshpal=true;
3795 }
3796
3797
2/2
✓ Branch 0 taken 6298112 times.
✓ Branch 1 taken 212553 times.
6510665 if(refreshpal)
3798 {
3799 212553 refreshpal=false;
3800 212553 RAMpal[253] = _RGB(0,0,0);
3801 212553 RAMpal[254] = _RGB(63,63,63);
3802 212553 hw_palette = &RAMpal;
3803 212553 update_hw_pal = true;
3804
3805 212553 create_rgb_table(&rgb_table, RAMpal, NULL);
3806 212553 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3807 212553 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3808
3809
2/2
✓ Branch 0 taken 54413568 times.
✓ Branch 1 taken 212553 times.
54626121 for(int32_t q=0; q<PAL_SIZE; q++)
3810 {
3811 54413568 trans_table2.data[0][q] = q;
3812 54413568 trans_table2.data[q][q] = q;
3813 54413568 }
3814 212553 }
3815
3816 6510665 bool clearwavy = (wavy <= 0);
3817
3818
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 6503420 times.
6510665 if(wavy <= 0)
3819 {
3820 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3821 6503420 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3822 6503420 }
3823
3824 6510665 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3825
3826
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 6479714 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
6510665 if(wavy && Playing && allowwavy)
3827 {
3828 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3829 30701 }
3830
3831
2/2
✓ Branch 0 taken 6503420 times.
✓ Branch 1 taken 7245 times.
6510665 if(clearwavy)
3832 6503420 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3833
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3834 7245 wavy--; // Wavy was set by a script. Decrement it.
3835
3836
5/6
✓ Branch 0 taken 6428643 times.
✓ Branch 1 taken 82022 times.
✓ Branch 2 taken 125857 times.
✓ Branch 3 taken 6302786 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 125857 times.
6510665 if(Playing && msgpos && !screenscrolling)
3837 {
3838
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_bg_display_buf->clip))
3839 125857 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3840
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_portrait_display_buf->clip))
3841 125857 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3842
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_txt_display_buf->clip))
3843 125857 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3844 125857 }
3845
3846 /*
3847 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3848 {
3849 BITMAP* subBmp = 0;
3850 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3851 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3852 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3853 destroy_bitmap(subBmp);
3854 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3855 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3856 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3857 }
3858 */
3859
3860
2/2
✓ Branch 0 taken 6485486 times.
✓ Branch 1 taken 25179 times.
6510665 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3861
3862
2/2
✓ Branch 0 taken 6485486 times.
✓ Branch 1 taken 25179 times.
6510665 if(nosubscr)
3863 {
3864 25179 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3865 25179 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3866 25179 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3867 25179 }
3868
3869 //TODO: Optimize blit 'overcalls' -Gleeok
3870
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 6485486 times.
6510665 BITMAP *source = nosubscr ? panorama : wavybuf;
3871 6510665 blit(source,framebuf,0,0,0,0,256,224);
3872
3873 6510665 update_hw_screen();
3874 6510665 }
3875
3876 //----------------------------------------------------------------
3877
3878 PALETTE sys_pal;
3879
3880 int32_t onGUISnapshot()
3881 {
3882 char buf[200];
3883 int32_t num=0;
3884 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3885 do
3886 {
3887 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3888 }
3889 while(num<99999 && exists(buf));
3890
3891 BITMAP *b = create_bitmap_ex(8,resx,resy);
3892
3893 if(b)
3894 {
3895 if(MenuOpen)
3896 {
3897 //Cannot load game's palette while GUI elements are in focus. -Z
3898 //If there is a way to do this, then I have missed it.
3899 /*
3900 game_pal();
3901 RAMpal[253] = _RGB(0,0,0);
3902 RAMpal[254] = _RGB(63,63,63);
3903 zc_set_palette_range(RAMpal,0,255,false);
3904 memcpy(RAMpal, snappal, sizeof(snappal));
3905 create_rgb_table(&rgb_table, RAMpal, NULL);
3906 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3907 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3908
3909 for(int32_t q=0; q<PAL_SIZE; q++)
3910 {
3911 trans_table2.data[0][q] = q;
3912 trans_table2.data[q][q] = q;
3913 }
3914 */
3915 //ringcolor(false);
3916 //get_palette(RAMpal);
3917 blit(screen,b,0,0,0,0,resx,resy);
3918 //al_trace("Menu Open\n");
3919 //game_pal();
3920 //PALETTE temppal;
3921 //get_palette(temppal);
3922 //system_pal();
3923 save_bitmap(buf,b,sys_pal);
3924 //save_bitmap(buf,b,RAMpal);
3925 //save_bitmap(buf,b,snappal);
3926 }
3927 else
3928 {
3929 blit(screen,b,0,0,0,0,resx,resy);
3930 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3931 }
3932 destroy_bitmap(b);
3933 }
3934
3935 return D_O_K;
3936 }
3937
3938 int32_t onNonGUISnapshot()
3939 {
3940 PALETTE temppal;
3941 get_palette(temppal);
3942 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3943
3944 char buf[200];
3945 int32_t num=0;
3946
3947 do
3948 {
3949 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3950 }
3951 while(num<99999 && exists(buf));
3952
3953 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3954
3955 return D_O_K;
3956 }
3957
3958 int32_t onSnapshot()
3959 {
3960 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3961 {
3962 onGUISnapshot();
3963 }
3964 else
3965 {
3966 onNonGUISnapshot();
3967 }
3968
3969 return D_O_K;
3970 }
3971
3972 int32_t onSaveMapPic()
3973 {
3974 int32_t mapres2 = 0;
3975 char buf[200];
3976 int32_t num=0;
3977 mapscr tmpscr_b[2];
3978 mapscr tmpscr_c[6];
3979 BITMAP* _screen_draw_buffer = NULL;
3980 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3981 set_clip_state(_screen_draw_buffer,1);
3982
3983 for(int32_t i=0; i<6; ++i)
3984 {
3985 tmpscr_c[i] = tmpscr2[i];
3986 tmpscr2[i].zero_memory();
3987
3988 if(i>=2)
3989 {
3990 continue;
3991 }
3992
3993 tmpscr_b[i] = tmpscr[i];
3994 tmpscr[i].zero_memory();
3995 }
3996
3997 do
3998 {
3999 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4000 }
4001 while(num<99999 && exists(buf));
4002
4003 BITMAP* mappic = NULL;
4004
4005
4006 bool done=false, redraw=true;
4007
4008 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4009
4010 if(!mappic)
4011 {
4012 system_pal();
4013 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4014 game_pal();
4015 return D_O_K;;
4016 }
4017
4018 // draw the map
4019 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4020
4021 for(int32_t y=0; y<8; y++)
4022 {
4023 for(int32_t x=0; x<16; x++)
4024 {
4025 if(!displayOnMap(x, y))
4026 {
4027 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4028 }
4029 else
4030 {
4031 int32_t s = (y<<4) + x;
4032 loadscr2(1,s,-1);
4033
4034 for(int32_t i=0; i<6; i++)
4035 {
4036 if(tmpscr[1].layermap[i]<=0)
4037 continue;
4038
4039 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4040 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4041 {
4042 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4043
4044 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4045 }
4046 }
4047
4048 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4049
4050 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4051
4052 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4053 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4054
4055 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4056
4057 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4058 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4059 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4060 {
4061 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4062 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4063 }
4064 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4065
4066 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4067
4068 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4069 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4070 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4071 {
4072 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4073 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4074 }
4075 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4076 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4077
4078 }
4079
4080 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4081 }
4082 }
4083
4084 for(int32_t i=0; i<6; ++i)
4085 {
4086 tmpscr2[i]=tmpscr_c[i];
4087
4088 if(i>=2)
4089 {
4090 continue;
4091 }
4092
4093 tmpscr[i]=tmpscr_b[i];
4094 }
4095
4096 save_bitmap(buf,mappic,RAMpal);
4097 destroy_bitmap(mappic);
4098 destroy_bitmap(_screen_draw_buffer);
4099 return D_O_K;
4100 }
4101
4102 /*
4103 int32_t onSaveMapPic()
4104 {
4105 BITMAP* mappic = NULL;
4106 BITMAP* _screen_draw_buffer = NULL;
4107 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4108 int32_t mapres2 = 0;
4109 char buf[20];
4110 int32_t num=0;
4111 set_clip_state(_screen_draw_buffer,1);
4112 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4113
4114 do
4115 {
4116 sprintf(buf, "zelda%03d.png", ++num);
4117 }
4118 while(num<999 && exists(buf));
4119
4120 // if(!mappic) {
4121 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4122
4123 if(!mappic)
4124 {
4125 system_pal();
4126 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4127 game_pal();
4128 return D_O_K;
4129 }
4130
4131 // }
4132
4133 int32_t layermap, layerscreen;
4134 int32_t x2=0;
4135
4136 // draw the map
4137 for(int32_t y=0; y<8; y++)
4138 {
4139 for(int32_t x=0; x<16; x++)
4140 {
4141 int32_t s = (y<<4) + x;
4142
4143 if(!displayOnMap(x, y))
4144 {
4145 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4146 }
4147 else
4148 {
4149 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4150 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4151
4152 for(int32_t k=0; k<4; k++)
4153 {
4154 if(k==2)
4155 {
4156 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4157 }
4158
4159 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4160
4161 if(layermap>-1)
4162 {
4163 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4164
4165 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4166 {
4167 for(int32_t i=0; i<176; i++)
4168 {
4169 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4170 }
4171 }
4172 else
4173 {
4174 for(int32_t i=0; i<176; i++)
4175 {
4176 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4177 }
4178 }
4179 }
4180 }
4181
4182 for(int32_t i=0; i<176; i++)
4183 {
4184 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4185 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4186 {
4187 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4188 }
4189 }
4190
4191 for(int32_t k=4; k<6; k++)
4192 {
4193 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4194
4195 if(layermap>-1)
4196 {
4197 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4198
4199 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4200 {
4201 for(int32_t i=0; i<176; i++)
4202 {
4203 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4204 }
4205 }
4206 else
4207 {
4208 for(int32_t i=0; i<176; i++)
4209 {
4210 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4211 }
4212 }
4213 }
4214 }
4215 }
4216
4217 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4218 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4219 }
4220
4221 }
4222
4223 save_bitmap(buf,mappic,RAMpal);
4224 destroy_bitmap(mappic);
4225 destroy_bitmap(_screen_draw_buffer);
4226 return D_O_K;
4227 }
4228 */
4229
4230 14 void f_Quit(int32_t type)
4231 {
4232
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4233 return;
4234
4235 14 bool from_menu = is_sys_pal;
4236
4237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4238 {
4239 14 music_pause();
4240 14 pause_all_sfx();
4241 14 }
4242 14 enter_sys_pal();
4243 14 clear_keybuf();
4244
4245
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4246 14 replay_poll();
4247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4248 14 replay_peek_quit();
4249
4250
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4251 switch(type)
4252 {
4253 case qQUIT:
4254 onQuit();
4255 break;
4256
4257 case qRESET:
4258 onReset();
4259 break;
4260
4261 case qEXIT:
4262 onExit();
4263 break;
4264 }
4265
4266
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4267 {
4268 14 kill_sfx();
4269 14 music_stop();
4270 14 exit_sys_pal();
4271 14 update_hw_screen();
4272 14 }
4273 else
4274 {
4275 exit_sys_pal();
4276 if(!from_menu)
4277 {
4278 music_resume();
4279 resume_all_sfx();
4280 }
4281 }
4282
4283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4284 14 eat_buttons();
4285
4286 14 zc_readrawkey(KEY_ESC);
4287
4288 14 zc_readrawkey(KEY_ENTER);
4289 14 }
4290
4291 //----------------------------------------------------------------
4292
4293 int32_t onNoWalls()
4294 {
4295 cheats_enqueue(Cheat::Walls);
4296 return D_O_K;
4297 }
4298
4299 int32_t onIgnoreSideview()
4300 {
4301 cheats_enqueue(Cheat::IgnoreSideView);
4302 return D_O_K;
4303 }
4304
4305 6510614 int32_t input_idle(bool checkmouse)
4306 {
4307 static int32_t mx, my, mz, mb;
4308
4309
4/6
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621032 times.
✓ Branch 3 taken 4889582 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1621032 times.
8131646 if(keypressed() || zc_key_pressed() ||
4310
4/8
✓ Branch 0 taken 1621032 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621032 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1621032 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1621032 times.
✗ Branch 7 not taken.
1621032 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4311 {
4312 4889582 idle_count = 0;
4313
4314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4889582 times.
4889582 if(active_count < MAX_ACTIVE)
4315 {
4316 4889582 ++active_count;
4317 4889582 }
4318 4889582 }
4319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1621032 times.
1621032 else if(idle_count < MAX_IDLE)
4320 {
4321 1621032 ++idle_count;
4322 1621032 active_count = 0;
4323 1621032 }
4324
4325 6510614 mx = mouse_x;
4326 6510614 my = mouse_y;
4327 6510614 mz = mouse_z;
4328 6510614 mb = mouse_b;
4329
4330 6510614 return idle_count;
4331 }
4332
4333 int32_t onGoFast()
4334 {
4335 cheats_enqueue(Cheat::Fast);
4336 return D_O_K;
4337 }
4338
4339 int32_t onKillCheat()
4340 {
4341 cheats_enqueue(Cheat::Kill);
4342 return D_O_K;
4343 }
4344
4345 int32_t onSecretsCheat()
4346 {
4347 cheats_enqueue(Cheat::TrigSecrets);
4348 return D_O_K;
4349 }
4350 int32_t onSecretsCheatPerm()
4351 {
4352 cheats_enqueue(Cheat::TrigSecretsPerm);
4353 return D_O_K;
4354 }
4355
4356 int32_t onShowLayer0()
4357 {
4358 show_layer_0 = !show_layer_0;
4359 return D_O_K;
4360 }
4361 int32_t onShowLayer1()
4362 {
4363 show_layer_1 = !show_layer_1;
4364 return D_O_K;
4365 }
4366 int32_t onShowLayer2()
4367 {
4368 show_layer_2 = !show_layer_2;
4369 return D_O_K;
4370 }
4371 int32_t onShowLayer3()
4372 {
4373 show_layer_3 = !show_layer_3;
4374 return D_O_K;
4375 }
4376 int32_t onShowLayer4()
4377 {
4378 show_layer_4 = !show_layer_4;
4379 return D_O_K;
4380 }
4381 int32_t onShowLayer5()
4382 {
4383 show_layer_5 = !show_layer_5;
4384 return D_O_K;
4385 }
4386 int32_t onShowLayer6()
4387 {
4388 show_layer_6 = !show_layer_6;
4389 return D_O_K;
4390 }
4391 int32_t onShowLayerO()
4392 {
4393 show_layer_over=!show_layer_over;
4394 return D_O_K;
4395 }
4396 int32_t onShowLayerP()
4397 {
4398 show_layer_push=!show_layer_push;
4399 return D_O_K;
4400 }
4401 int32_t onShowLayerS()
4402 {
4403 show_sprites=!show_sprites;
4404 return D_O_K;
4405 }
4406 int32_t onShowLayerF()
4407 {
4408 show_ffcs=!show_ffcs;
4409 return D_O_K;
4410 }
4411 int32_t onShowLayerW()
4412 {
4413 show_walkflags=!show_walkflags;
4414 if(show_walkflags)
4415 show_effectflags = false;
4416 return D_O_K;
4417 }
4418 int32_t onShowLayerE()
4419 {
4420 show_effectflags=!show_effectflags;
4421 if(show_effectflags)
4422 show_walkflags = false;
4423 return D_O_K;
4424 }
4425 int32_t onShowFFScripts()
4426 {
4427 show_ff_scripts=!show_ff_scripts;
4428 return D_O_K;
4429 }
4430 int32_t onShowHitboxes()
4431 {
4432 show_hitboxes=!show_hitboxes;
4433 return D_O_K;
4434 }
4435 int32_t onShowInfoOpacity()
4436 {
4437 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4438 zc_set_config("zc","debug_info_opacity",info_opacity);
4439 return D_O_K;
4440 }
4441
4442 int32_t onLightSwitch()
4443 {
4444 cheats_enqueue(Cheat::Light);
4445 return D_O_K;
4446 }
4447
4448 int32_t onGoTo();
4449 int32_t onGoToComplete();
4450
4451 6510614 void syskeys()
4452 {
4453 6510614 update_system_keys();
4454
4455 int32_t oldtitle_version;
4456
4457
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(close_button_quit)
4458 {
4459 close_button_quit=false;
4460 f_Quit(qEXIT);
4461 }
4462
4463 6510614 poll_joystick();
4464
4465
2/10
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6510614 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
6510614 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4466 {
4467 oldtitle_version=title_version;
4468 System();
4469 }
4470
4471 6510614 mouse_down=gui_mouse_b();
4472
4473
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F1))
4474 {
4475 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4476 {
4477 halt=!halt;
4478 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4479 }
4480 else
4481 {
4482 Throttlefps=!Throttlefps;
4483 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4484 logic_counter=0;
4485 }
4486 }
4487
4488 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4489 /*
4490 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4491 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4492 */
4493
4494
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F2))
4495 {
4496 ShowFPS=!ShowFPS;
4497 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4498 }
4499
4500
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4501
4502
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(zc_read_system_key(KEY_F4) && Playing)
4503 {
4504 Paused=true;
4505 Advance=true;
4506 }
4507
4508
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F6)) onTryQuit();
4509
4510 #ifndef ALLEGRO_MACOSX
4511
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4512
4513
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4514 #else
4515 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4516
4517 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4518 #endif
4519
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6510614 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4520
4521
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if (zc_read_system_key(KEY_F12))
4522 {
4523 onSnapshot();
4524 }
4525
4526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(debug_enabled && zc_read_system_key(KEY_TAB))
4527 set_debug(!get_debug());
4528
4529
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(CheatModifierKeys())
4530 {
4531 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4532 {
4533 if(!bindable_cheat(c))
4534 continue;
4535 if(get_debug() || cheat >= cheat_lvl(c))
4536 {
4537 if(checkcheat(c))
4538 cheats_hit_bind(c);
4539 }
4540 }
4541 }
4542
4543
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(volkeys)
4544 {
4545 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4546
4547 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4548
4549 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4550
4551 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4552 }
4553
4554
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6510614 if(!get_debug() || !SystemKeys || replay_is_replaying())
4555 6510614 goto bottom;
4556
4557 if(zc_readkey(KEY_D))
4558 {
4559 details = !details;
4560 rectfill(screen,0,0,319,7,BLACK);
4561 rectfill(screen,0,8,31,239,BLACK);
4562 rectfill(screen,288,8,319,239,BLACK);
4563 rectfill(screen,32,232,287,239,BLACK);
4564 }
4565
4566 if(zc_readkey(KEY_P)) Paused=!Paused;
4567
4568 //if(zc_readkey(KEY_P)) centerHero();
4569 if(zc_readkey(KEY_A))
4570 {
4571 Paused=true;
4572 Advance=true;
4573 }
4574
4575 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4576 #ifndef ALLEGRO_MACOSX
4577 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4578
4579 if(zc_readkey(KEY_F7))
4580 {
4581 Matrix(ss_speed, ss_density, 0);
4582 game_pal();
4583 }
4584 #else
4585 // The reason these are different on Mac in the first place is that
4586 // the OS doesn't let us use F9 and F10...
4587 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4588
4589 if(zc_readkey(KEY_F9))
4590 {
4591 Matrix(ss_speed, ss_density, 0);
4592 game_pal();
4593 }
4594 #endif
4595 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4596 {
4597 //change containers
4598 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4599 {
4600 //magic containers
4601 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4602 {
4603 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4604 }
4605 else
4606 {
4607 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4608 }
4609 }
4610 else
4611 {
4612 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4613 {
4614 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4615 }
4616 else
4617 {
4618 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4619 }
4620 }
4621 }
4622
4623 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4624 {
4625 //change containers
4626 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4627 {
4628 //magic containers
4629 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4630 {
4631 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4632 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4633 //heart containers
4634 }
4635 else
4636 {
4637 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4638 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4639 }
4640 }
4641 else
4642 {
4643 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4644 {
4645 game->set_magic(zc_max(game->get_magic()-1,0));
4646 }
4647 else
4648 {
4649 game->set_life(zc_max(game->get_life()-1,0));
4650 }
4651 }
4652 }
4653
4654 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4655
4656 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4657
4658 verifyBothWeapons();
4659
4660 bottom:
4661
4662
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(input_idle(true) > after_time())
4663 {
4664 Matrix(ss_speed, ss_density, 0);
4665 game_pal();
4666 }
4667 6510614 }
4668
4669 330136 void checkQuitKeys()
4670 {
4671 #ifndef ALLEGRO_MACOSX
4672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F9]) f_Quit(qRESET);
4673
4674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F10]) f_Quit(qEXIT);
4675 #else
4676 if(key[KEY_F7]) f_Quit(qRESET);
4677
4678 if(key[KEY_F8]) f_Quit(qEXIT);
4679 #endif
4680 330136 }
4681
4682 6510614 bool CheatModifierKeys()
4683 {
4684 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4685 // to trigger cheats.
4686
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if (replay_is_replaying())
4687 6510614 return false;
4688
4689 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4690 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4691 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4692 {
4693 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4694 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4695 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4696 {
4697 return true;
4698 }
4699 }
4700 return false;
4701 6510614 }
4702
4703 //99:05:54, for some reason?
4704 #define OLDMAXTIME 21405240
4705 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4706 #define MAXTIME 1944000000
4707
4708 6510665 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4709 {
4710
2/2
✓ Branch 0 taken 6242564 times.
✓ Branch 1 taken 268101 times.
6510665 if(zcmusic!=NULL)
4711 {
4712 268101 zcmusic_poll();
4713 268101 }
4714
4715 6510665 updatescr(allowwavy);
4716
4717 6510665 Advance=false;
4718
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6510665 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6510665 times.
6510665 while(Paused && !Advance && !Quit)
4719 {
4720 // have to call this, otherwise we'll get an infinite loop
4721 syskeys();
4722 if(allowF6Script)
4723 {
4724 FFCore.runF6Engine();
4725 }
4726 throttleFPS();
4727
4728 #ifdef _WIN32
4729
4730 if(use_dwm_flush)
4731 {
4732 do_DwmFlush();
4733 }
4734
4735 #endif
4736
4737 // to keep music playing
4738 if(zcmusic!=NULL)
4739 {
4740 zcmusic_poll();
4741 }
4742
4743 update_hw_screen();
4744 }
4745
4746
2/2
✓ Branch 0 taken 6510624 times.
✓ Branch 1 taken 41 times.
6510665 if(Quit)
4747 41 return;
4748
4749
3/4
✓ Branch 0 taken 6428635 times.
✓ Branch 1 taken 81989 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6428635 times.
6510624 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4750 6428635 game->change_time(1);
4751
4752
2/4
✓ Branch 0 taken 6510624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6510624 times.
6510624 if (!replay_is_active() || replay_get_version() >= 11)
4753 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4754 down_control_states[i] = raw_control_state[i];
4755
4756
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510622 times.
6510624 if (replay_is_active())
4757 {
4758
2/2
✓ Branch 0 taken 1270461 times.
✓ Branch 1 taken 5240161 times.
6510622 if (replay_get_version() >= 3)
4759 5240161 replay_poll();
4760
4761
5/6
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3089962 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 2989427 times.
6510622 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4762 100535 replay_peek_input();
4763 6510614 }
4764
4765 6510624 load_control_called_this_frame = false;
4766
4767 6510624 poll_keyboard();
4768 6510624 update_keys();
4769
4770 6510624 ++frame;
4771
4772
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510614 times.
6510624 if (replay_is_replaying())
4773 6510614 replay_do_cheats();
4774 6510624 syskeys();
4775
4776 // The mouse variables can change from the mouse thread at anytime during a frame,
4777 // so save the result at the start so that replaying is consistent.
4778 6510624 script_mouse_x = gui_mouse_x();
4779 6510624 script_mouse_y = gui_mouse_y();
4780 6510624 script_mouse_z = mouse_z;
4781 6510624 script_mouse_b = mouse_b;
4782
4783 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4784 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4785 // approach here means it doesn't matter which call adds the cheat.
4786 6510624 cheats_execute_queued();
4787
4788
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510614 times.
6510624 if (replay_is_replaying())
4789 6510614 replay_peek_quit();
4790
2/2
✓ Branch 0 taken 6510610 times.
✓ Branch 1 taken 14 times.
6510624 if (GameFlags & GAMEFLAG_TRYQUIT)
4791 14 replay_step_quit(0);
4792
2/2
✓ Branch 0 taken 1835 times.
✓ Branch 1 taken 6508789 times.
6510624 if(allowF6Script)
4793 6508789 FFCore.runF6Engine();
4794
2/2
✓ Branch 0 taken 6510449 times.
✓ Branch 1 taken 175 times.
6510624 if (Quit)
4795 175 replay_step_quit(Quit);
4796 // Someday... maybe install a Turbo button here?
4797 6510624 throttleFPS();
4798
4799 #ifdef _WIN32
4800
4801 if(use_dwm_flush)
4802 {
4803 do_DwmFlush();
4804 }
4805
4806 #endif
4807
4808 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4809
2/2
✓ Branch 0 taken 29901 times.
✓ Branch 1 taken 6480723 times.
6510624 if(sfxcleanup)
4810 6480723 sfx_cleanup();
4811 6510665 }
4812
4813 59 void zapout()
4814 {
4815 59 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4816 59 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4817
4818 59 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4819 59 script_drawing_commands.Clear();
4820
4821 // zap out
4822
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1416 times.
1475 for(int32_t i=1; i<=24; i++)
4823 {
4824 1416 draw_fuzzy(i);
4825 1416 advanceframe(true);
4826
4827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1416 times.
1416 if(Quit)
4828 {
4829 break;
4830 }
4831 1416 }
4832 59 }
4833
4834 59 void zapin()
4835 {
4836 59 FFCore.warpScriptCheck();
4837 59 draw_screen(tmpscr);
4838 59 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4839 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4840 59 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4841
4842 // zap out
4843 59 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4844
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1416 times.
1475 for(int32_t i=24; i>=1; i--)
4845 {
4846 1416 draw_fuzzy(i);
4847 1416 advanceframe(true);
4848
4849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1416 times.
1416 if(Quit)
4850 {
4851 break;
4852 }
4853 1416 }
4854 59 }
4855
4856
4857 23 void wavyout(bool showhero)
4858 {
4859 23 draw_screen(tmpscr, showhero);
4860 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4861
4862 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4863 23 clear_to_color(wavebuf,0);
4864 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4865
4866 static PALETTE wavepal;
4867
4868 int32_t ofs;
4869 23 int32_t amplitude=8;
4870
4871 23 int32_t wavelength=4;
4872 23 double palpos=0, palstep=4, palstop=126;
4873
4874 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4875
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4876 {
4877
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4878 {
4879 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4880 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4881 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4882 247296 }
4883
4884 966 palpos+=palstep;
4885
4886
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4887 {
4888 966 hw_palette = &wavepal;
4889 966 update_hw_pal = true;
4890 966 }
4891 else
4892 {
4893 hw_palette = &RAMpal;
4894 update_hw_pal = true;
4895 }
4896
4897
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4898 {
4899
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4900 {
4901 41545728 ofs=0;
4902
4903
4/4
✓ Branch 0 taken 20278272 times.
✓ Branch 1 taken 21267456 times.
✓ Branch 2 taken 10139136 times.
✓ Branch 3 taken 10139136 times.
41545728 if((j<i)&&(j&1))
4904 {
4905 10139136 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4906 10139136 }
4907
4908 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4909 41545728 }
4910 162288 }
4911
4912 966 advanceframe(true);
4913
4914 // animate_combos();
4915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4916 break;
4917 966 }
4918
4919 23 destroy_bitmap(wavebuf);
4920 23 }
4921
4922 23 void wavyin()
4923 {
4924 23 draw_screen(tmpscr);
4925 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4926
4927 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4928 23 clear_to_color(wavebuf,0);
4929 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4930
4931 static PALETTE wavepal;
4932
4933 //Breaks dark rooms.
4934 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4935 /*
4936 loadfullpal();
4937 loadlvlpal(DMaps[currdmap].color);
4938 ringcolor(false);
4939 */
4940 23 refreshpal=false;
4941 int32_t ofs;
4942 23 int32_t amplitude=8;
4943 23 int32_t wavelength=4;
4944 23 double palpos=168, palstep=4, palstop=126;
4945
4946 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4947
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4948 {
4949
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4950 {
4951 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4952 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4953 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4954 247296 }
4955
4956 966 palpos-=palstep;
4957
4958
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4959 {
4960 966 hw_palette = &wavepal;
4961 966 update_hw_pal = true;
4962 966 }
4963 else
4964 {
4965 hw_palette = &RAMpal;
4966 update_hw_pal = true;
4967 }
4968
4969
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4970 {
4971
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4972 {
4973 41545728 ofs=0;
4974
4975
4/4
✓ Branch 0 taken 21020160 times.
✓ Branch 1 taken 20525568 times.
✓ Branch 2 taken 10633728 times.
✓ Branch 3 taken 10386432 times.
41545728 if((j<(167-i))&&(j&1))
4976 {
4977 10386432 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4978 10386432 }
4979
4980 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4981 41545728 }
4982 162288 }
4983
4984 966 advanceframe(true);
4985 // animate_combos();
4986
4987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4988 break;
4989 966 }
4990
4991 23 destroy_bitmap(wavebuf);
4992 23 }
4993
4994 1619 void blackscr(int32_t fcnt,bool showsubscr)
4995 {
4996 1619 reset_pal_cycling();
4997 1619 script_drawing_commands.Clear();
4998
4999 1619 FFCore.warpScriptCheck();
5000 1619 bool showtime = game->should_show_time();
5001
2/2
✓ Branch 0 taken 1619 times.
✓ Branch 1 taken 48500 times.
50119 while(fcnt>0)
5002 {
5003 48500 clear_bitmap(framebuf);
5004
5005
2/2
✓ Branch 0 taken 13500 times.
✓ Branch 1 taken 35000 times.
48500 if(showsubscr)
5006 {
5007 35000 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5008
3/4
✓ Branch 0 taken 35000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 34250 times.
35000 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5009 {
5010 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5011 750 }
5012 35000 }
5013
5014 48500 advanceframe(true);
5015
5016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48500 times.
48500 if(Quit)
5017 break;
5018
5019 48500 --fcnt;
5020 }
5021 1619 }
5022
5023 563 void openscreen(int32_t shape)
5024 {
5025 563 reset_pal_cycling();
5026 563 black_opening_count=0;
5027
5028
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 465 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
563 if(COOLSCROLL || shape>-1)
5029 {
5030 465 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5031 465 return;
5032 }
5033 else
5034 {
5035 98 Hero.setDontDraw(true);
5036 98 show_subscreen_dmap_dots=false;
5037 98 show_subscreen_numbers=false;
5038 // show_subscreen_items=false;
5039 98 show_subscreen_life=false;
5040 }
5041
5042 98 int32_t x=128;
5043
5044 98 FFCore.warpScriptCheck();
5045
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5046 {
5047 7840 draw_screen(tmpscr);
5048 //? draw_screen already draws the subscreen -DD
5049 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5050 7840 x=128-(((i*128/80)/8)*8);
5051
5052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5053 {
5054 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5055 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5056 7840 }
5057
5058 7840 advanceframe(true);
5059
5060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5061 {
5062 break;
5063 }
5064 7840 }
5065
5066 98 Hero.setDontDraw(false);
5067 98 show_subscreen_items=true;
5068 98 show_subscreen_dmap_dots=true;
5069 563 }
5070
5071 void closescreen(int32_t shape)
5072 {
5073 reset_pal_cycling();
5074 black_opening_count=0;
5075
5076 if(COOLSCROLL || shape>-1)
5077 {
5078 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5079 return;
5080 }
5081 else
5082 {
5083 Hero.setDontDraw(true);
5084 show_subscreen_dmap_dots=false;
5085 show_subscreen_numbers=false;
5086 // show_subscreen_items=false;
5087 show_subscreen_life=false;
5088 }
5089
5090 int32_t x=128;
5091
5092 FFCore.warpScriptCheck();
5093 for(int32_t i=79; i>=0; --i)
5094 {
5095 draw_screen(tmpscr);
5096 //? draw_screen already draws the subscreen -DD
5097 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5098 x=128-(((i*128/80)/8)*8);
5099
5100 if(x>0)
5101 {
5102 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5103 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5104 }
5105
5106 advanceframe(true);
5107
5108 if(Quit)
5109 {
5110 break;
5111 }
5112 }
5113
5114 Hero.setDontDraw(false);
5115 show_subscreen_items=true;
5116 show_subscreen_dmap_dots=true;
5117 }
5118
5119 122 int32_t TriforceCount()
5120 {
5121 122 int32_t c=0;
5122
5123
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 122 times.
1098 for(int32_t i=1; i<=8; i++)
5124
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 650 times.
1626 if(game->lvlitems[i]&liTRIFORCE)
5125 650 ++c;
5126
5127 122 return c;
5128 }
5129
5130 int32_t onCustomGame()
5131 {
5132 int32_t file = getsaveslot();
5133
5134 if(file < 0)
5135 return D_O_K;
5136
5137 bool ret = (custom_game(file)!=0);
5138 return ret ? D_CLOSE : D_O_K;
5139 }
5140
5141 int32_t onContinue()
5142 {
5143 return D_CLOSE;
5144 }
5145
5146 int32_t onEsc() // Unused?? -L
5147 {
5148 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5149 }
5150
5151 int32_t onVsync()
5152 {
5153 Throttlefps = !Throttlefps;
5154 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5155 return D_O_K;
5156 }
5157
5158 int32_t onWinPosSave()
5159 {
5160 SaveWinPos = !SaveWinPos;
5161 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5162 return D_O_K;
5163 }
5164 int32_t onIntegerScaling()
5165 {
5166 scaleForceInteger = !scaleForceInteger;
5167 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5168 return D_O_K;
5169 }
5170
5171 int32_t onClickToFreeze()
5172 {
5173 ClickToFreeze = !ClickToFreeze;
5174 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5175 return D_O_K;
5176 }
5177
5178 int32_t OnSaveZCConfig()
5179 {
5180 if(jwin_alert3(
5181 "Save Configuration",
5182 "Are you sure that you wish to save your present configuration settings?",
5183 "This will overwrite your prior settings!",
5184 NULL,
5185 "&Yes",
5186 "&No",
5187 NULL,
5188 'y',
5189 'n',
5190 0,
5191 lfont) == 1)
5192 {
5193 save_game_configs();
5194 return D_O_K;
5195 }
5196 else return D_O_K;
5197 }
5198
5199 int32_t OnnClearQuestDir()
5200 {
5201 if(jwin_alert3(
5202 "Clear Current Directory Cache",
5203 "Are you sure that you wish to clear the current cached directory?",
5204 "This will default the current directory to the ROOT for this instance of ZC Player!",
5205 NULL,
5206 "&Yes",
5207 "&No",
5208 NULL,
5209 'y',
5210 'n',
5211 0,
5212 lfont) == 1)
5213 {
5214 zc_set_config("zeldadx","win_qst_dir","");
5215 flush_config_file();
5216 strcpy(qstdir,"");
5217 #ifdef __EMSCRIPTEN__
5218 em_sync_fs();
5219 #endif
5220 return D_O_K;
5221 }
5222 else return D_O_K;
5223 }
5224
5225
5226 int32_t onConsoleZASM()
5227 {
5228 if ( !zasm_debugger )
5229 {
5230 AlertDialog("WARNING: ZASM Debugger",
5231 "Enabling this will open the ZASM Debugger Console"
5232 "\nThis will likely grind ZC to a halt with lag."
5233 "\nTo make any use of this, it is suggested that you read"
5234 "\nthe documentation for 'void Breakpoint(char[] string);'"
5235 " in 'ZScript_Additions.txt'"
5236 "\nThis is not recommended for normal users,"
5237 " and is only intended for ZC developers,"
5238 "\nor quest developers coding directly in ZASM"
5239 "\nAre you sure that you wish to open the ZASM Debugger?",
5240 [&](bool ret,bool)
5241 {
5242 if(ret)
5243 {
5244 FFCore.ZASMPrint(true);
5245 }
5246 }).show();
5247 return D_O_K;
5248 }
5249 else
5250 {
5251 FFCore.ZASMPrint(false);
5252 return D_O_K;
5253 }
5254 }
5255
5256
5257 int32_t onConsoleZScript()
5258 {
5259 if ( !zscript_debugger )
5260 {
5261 AlertDialog("ZScript Debugger",
5262 "Enabling this will open the ZScript Debugger Console"
5263 "\nThis will display any messages logged by scripts,"
5264 " including script errors."
5265 "\nAre you sure that you wish to open the ZScript Debugger?",
5266 [&](bool ret,bool)
5267 {
5268 if(ret)
5269 {
5270 FFCore.ZScriptConsole(true);
5271 }
5272 }).show();
5273 return D_O_K;
5274 }
5275 else
5276 {
5277 FFCore.ZScriptConsole(false);
5278 return D_O_K;
5279 }
5280 }
5281
5282 int32_t onClrConsoleOnReload()
5283 {
5284 clearConsoleOnReload = !clearConsoleOnReload;
5285 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5286 return D_O_K;
5287 }
5288 int32_t onClrConsoleOnLoad()
5289 {
5290 clearConsoleOnLoad = !clearConsoleOnLoad;
5291 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5292 return D_O_K;
5293 }
5294
5295
5296 int32_t onFrameSkip()
5297 {
5298 FrameSkip = !FrameSkip;
5299 return D_O_K;
5300 }
5301
5302 int32_t onSaveDragResize()
5303 {
5304 SaveDragResize = !SaveDragResize;
5305 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5306 return D_O_K;
5307 }
5308
5309 int32_t onDragAspect()
5310 {
5311 DragAspect = !DragAspect;
5312 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5313 return D_O_K;
5314 }
5315
5316 int32_t onTransLayers()
5317 {
5318 TransLayers = !TransLayers;
5319 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5320 return D_O_K;
5321 }
5322
5323 int32_t onNESquit()
5324 {
5325 NESquit = !NESquit;
5326 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5327 return D_O_K;
5328 }
5329
5330 int32_t onVolKeys()
5331 {
5332 volkeys = !volkeys;
5333 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5334 return D_O_K;
5335 }
5336
5337 int32_t onShowFPS()
5338 {
5339 ShowFPS = !ShowFPS;
5340 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5341 return D_O_K;
5342 }
5343
5344 768252452 bool is_Fkey(int32_t k)
5345 {
5346
2/2
✓ Branch 0 taken 78127368 times.
✓ Branch 1 taken 690125084 times.
768252452 switch(k)
5347 {
5348 case KEY_F1:
5349 case KEY_F2:
5350 case KEY_F3:
5351 case KEY_F4:
5352 case KEY_F5:
5353 case KEY_F6:
5354 case KEY_F7:
5355 case KEY_F8:
5356 case KEY_F9:
5357 case KEY_F10:
5358 case KEY_F11:
5359 case KEY_F12:
5360 78127368 return true;
5361 }
5362
5363 690125084 return false;
5364 768252452 }
5365
5366 void kb_getkey(DIALOG *d);
5367
5368 //Used by all keyboard key settings dialogues.
5369 void kb_clearjoystick(DIALOG *d)
5370 {
5371 d->flags|=D_SELECTED;
5372
5373 jwin_button_proc(MSG_DRAW,d,0);
5374 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5375 // text_mode(vc(11));
5376 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5377 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5378
5379 update_hw_screen(true);
5380
5381 clear_keybuf();
5382 int32_t k = next_press_key();
5383 clear_keybuf();
5384
5385 //shnarf
5386 //47=f1
5387 //59=esc
5388 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5389 // *((int32_t*)d->dp3) = k;
5390 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5391
5392
5393 d->flags&=~D_SELECTED;
5394 }
5395
5396 //Clears key to 0.
5397 //Used by all keyboard key settings dialogues.
5398 void kb_clearkey(DIALOG *d);
5399
5400 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5401 {
5402 switch(msg)
5403 {
5404 case MSG_KEY:
5405 case MSG_CLICK:
5406
5407 kb_clearjoystick(d);
5408
5409 while(gui_mouse_b())
5410 {
5411 clear_keybuf();
5412 rest(1);
5413 }
5414
5415 return D_REDRAW;
5416 }
5417
5418 return jwin_button_proc(msg,d,c);
5419 }
5420
5421 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5422 //Only used in keyboard settings dialogues to clear keys.
5423 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5424
5425 void j_getbtn(DIALOG *d)
5426 {
5427 d->flags|=D_SELECTED;
5428 jwin_button_proc(MSG_DRAW,d,0);
5429 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5430 // text_mode(vc(11));
5431 int32_t y = gui_bmp->h/2 - 12;
5432 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5433 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5434 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5435
5436 update_hw_screen(true);
5437
5438 int32_t b = next_press_btn();
5439
5440 if(b>=0)
5441 *((int32_t*)d->dp3) = b;
5442
5443 d->flags&=~D_SELECTED;
5444
5445 if (player)
5446 player->joy_on = TRUE;
5447 }
5448
5449 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5450 {
5451 switch(msg)
5452 {
5453 case MSG_KEY:
5454 case MSG_CLICK:
5455
5456 j_getbtn(d);
5457
5458 while(gui_mouse_b()) {
5459 rest(1);
5460 clear_keybuf();
5461 }
5462
5463 return D_REDRAW;
5464 }
5465
5466 return jwin_button_proc(msg,d,c);
5467 }
5468
5469 //shnarf
5470 extern const char *key_str[];
5471 std::string get_keystr(int key);
5472
5473 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5474 //extern int32_t zcmusic_bufsz;
5475
5476 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5477 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5478
5479 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5480 {
5481 //these are here to bypass compiler warnings about unused arguments
5482 c=c;
5483
5484 if(msg==MSG_DRAW)
5485 {
5486 switch(d->w)
5487 {
5488 case 0:
5489 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5490 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5491 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5492 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5493 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5494 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5495 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5496 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5497 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5498 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5499 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5500 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5501 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5502 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5503 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5504 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5505 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5506 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5507 break;
5508
5509 case 1:
5510 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5511 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5512 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5513 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5514 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5515 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5516 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5517 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5518 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5519 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5520 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5521 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5522 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5523 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5524 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5525 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5526 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5527 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5528 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5529 break;
5530
5531 case 2:
5532 sprintf(str_a," %3d",midi_volume);
5533 sprintf(str_b," %3d",digi_volume);
5534 sprintf(str_l," %3d",emusic_volume);
5535 sprintf(str_m," %3dKB",zcmusic_bufsz);
5536 sprintf(str_r," %3d",sfx_volume);
5537 strcpy(str_s,pan_str[pan_style]);
5538 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5539 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5540 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5541 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5542 break;
5543 }
5544 }
5545
5546 return D_O_K;
5547 }
5548
5549 int32_t set_vol(void *dp3, int32_t d2)
5550 {
5551 switch(((int32_t*)dp3)[0])
5552 {
5553 case 0:
5554 midi_volume = zc_min(d2<<3,255);
5555 break;
5556
5557 case 1:
5558 digi_volume = zc_min(d2<<3,255);
5559 break;
5560
5561 case 2:
5562 emusic_volume = zc_min(d2<<3,255);
5563 break;
5564
5565 case 3:
5566 sfx_volume = zc_min(d2<<3,255);
5567 break;
5568 }
5569
5570 // text_mode(vc(11));
5571 textprintf_right_ex(screen,lfont_l, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5572 return D_O_K;
5573 }
5574
5575 int32_t set_pan(void *dp3, int32_t d2)
5576 {
5577 pan_style = vbound(d2,0,3);
5578 // text_mode(vc(11));
5579 textout_right_ex(screen,lfont_l, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5580 return D_O_K;
5581 }
5582
5583 int32_t set_buf(void *dp3, int32_t d2)
5584 {
5585 // text_mode(vc(11));
5586 zcmusic_bufsz = d2 + 1;
5587 textprintf_right_ex(screen,lfont_l, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5588 return D_O_K;
5589 }
5590
5591 static int32_t gamepad_btn_list[] =
5592 {
5593 6,
5594 7,8,9,10,11,12,13,14,15,16,17,
5595 18,19,20,21,22,23,24,25,26,27,28,
5596 29,30,31,32,33,34,35,36,37,38,39,
5597 -1
5598 };
5599
5600 static int32_t gamepad_dirs_list[] =
5601 {
5602 40,41,42,43,
5603 44,45,46,47,
5604 48,49,50,51,
5605 52,53,54,55,
5606 56,
5607 -1
5608 };
5609
5610 static TABPANEL gamepad_tabs[] =
5611 {
5612 // (text)
5613 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5614 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5615 { NULL, 0, NULL, 0, NULL }
5616 };
5617
5618 static DIALOG gamepad_dlg[] =
5619 {
5620 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5621 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5622 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5623 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5624 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5625 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5626 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5627 // 6
5628 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5629 // 7
5630 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5631 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5632 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5633 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5634 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5635 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5636 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5637 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5638 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5639 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5640 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5641 // 18
5642 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5643 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5644 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5645 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5646 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5647 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5648 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5649 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5650 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5651 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5652 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5653 // 29
5654 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5655 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5656 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5657 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5658 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5659 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5660 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5661 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5662 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5663 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5664 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5665 // 40
5666 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5667 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5668 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5669 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5670 // 44
5671 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5672 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5673 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5674 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5675 // 48
5676 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5677 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5678 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5679 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5680 // 52
5681 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5682 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5683 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5684 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5685 // 56
5686 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5687 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5688 };
5689
5690 static int32_t keyboard_keys_list[] =
5691 {
5692 6,7,8,9,10,
5693 11,12,13,14,15,16,17,18,19,20,
5694 21,22,23,24,25,26,27,28,29,30,
5695 31,32,33,34,35,36,37,38,39,40,
5696 -1
5697 };
5698
5699 static int32_t keyboard_dirs_list[] =
5700 {
5701 41,42,43,44,
5702 45,46,47,48,
5703 49,50,51,52,
5704 53,54,55,56,
5705 -1
5706 };
5707
5708 static int32_t keyboard_mods_list[] =
5709 {
5710 57,58,59,60,
5711 61,62,63,64,
5712 65,66,67,68,
5713 69,70,71,72,
5714 -1
5715 };
5716
5717 static TABPANEL keyboard_control_tabs[] =
5718 {
5719 // (text)
5720 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5721 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5722 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5723 { NULL, 0, NULL, 0, NULL }
5724 };
5725
5726 static DIALOG keyboard_control_dlg[] =
5727 {
5728 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5729 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5730 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5731 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5732 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5733 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5734 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5735 // Keys
5736 // 6
5737 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5738 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5739 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5740 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5741 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5742 // 11
5743 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5744 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5745 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5746 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5747 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5748 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5749 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5750 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5751 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5752 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5753 // 21
5754 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5755 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5756 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5757 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5758 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5759 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5760 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5761 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5762 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5763 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5764 // 31
5765 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5766 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5767 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5768 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5769 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5770 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5771 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5772 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5773 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5774 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5775 // Dirs
5776 // 41
5777 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5778 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5779 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5780 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5781 // 45
5782 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5783 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5784 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5785 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5786 // 49
5787 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5788 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5789 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5790 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5791 // 53
5792 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5793 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5794 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5795 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5796 // Mods
5797 // 57
5798 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5799 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5800 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5801 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5802 // 61
5803 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5804 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5805 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5806 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5807 // 65
5808 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5809 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5810 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5811 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5812 // 69
5813 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5814 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5815 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5816 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5817 // 73
5818 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5819 };
5820
5821 /*
5822 int32_t midi_dp[3] = {0,147,104};
5823 int32_t digi_dp[3] = {1,147,120};
5824 int32_t pan_dp[3] = {0,147,136};
5825 int32_t buf_dp[3] = {0,147,152};
5826 */
5827 int32_t midi_dp[3] = {0,0,0};
5828 int32_t digi_dp[3] = {1,0,0};
5829 int32_t emus_dp[3] = {2,0,0};
5830 int32_t buf_dp[3] = {0,0,0};
5831 int32_t sfx_dp[3] = {3,0,0};
5832 int32_t pan_dp[3] = {0,0,0};
5833
5834 static DIALOG sound_dlg[] =
5835 {
5836 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5837 29 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5838 29 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5839 29 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5840 29 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5841 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5842 29 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5843 29 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5844 29 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5845 29 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5846 29 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5847 // 10
5848 29 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5849 29 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5850 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5851 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5852 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5853 29 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5854 29 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5855 29 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5856 29 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5857 29 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5858 //20
5859 29 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5860 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5861 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5862 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5863 29 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5864 29 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5865 29 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5866 29 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5867 29 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5868 29 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5869 //30
5870 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5871 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5872 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5873 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5874 };
5875
5876 char zc_builddate[80];
5877 char zc_aboutstr[80];
5878
5879 static DIALOG about_dlg[] =
5880 {
5881 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5882 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5883 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5884 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5885 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5886 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5887 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5888 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5889 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5890 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5891 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5892 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5893 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5894 };
5895
5896
5897 static DIALOG quest_dlg[] =
5898 {
5899 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5900 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5901 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5902 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5903 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5904 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5905 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5906 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5907 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5908 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5909 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5910 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5911 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5912 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5913 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5914 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5915 };
5916
5917 static DIALOG triforce_dlg[] =
5918 {
5919 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5920 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5921 // 1
5922 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5923 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5924 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5925 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5926 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5927 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5928 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5929 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5930 // 9
5931 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5932 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5933 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5934 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5935 };
5936
5937 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5938 {
5939 go();
5940 int32_t ret=0;
5941 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5942 comeback();
5943 return ret != 0;
5944 }
5945
5946
5947 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5948 {
5949 if(def!=modulepath)
5950 strcpy(modulepath,def);
5951
5952 if(!usefilename)
5953 {
5954 int32_t i=(int32_t)strlen(modulepath);
5955
5956 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5957 modulepath[i--]=0;
5958 }
5959
5960 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5961 int32_t ret=0;
5962 int32_t sel=0;
5963
5964 if(list==NULL)
5965 {
5966 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
5967 }
5968 else
5969 {
5970 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
5971 }
5972
5973 return ret!=0;
5974 }
5975
5976 //The Dialogue that loads a ZMOD Module File
5977 int32_t zc_load_zmod_module_file()
5978 {
5979 if ( Playing )
5980 {
5981 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
5982 return -1;
5983 }
5984 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5985 return D_CLOSE;
5986
5987 FILE *tempmodule = fopen(modulepath,"r");
5988
5989 if(tempmodule == NULL)
5990 {
5991 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
5992 return -1;
5993 }
5994
5995
5996 //Set the module path:
5997 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
5998 strcpy(moduledata.module_name, modulepath);
5999 al_trace("New Module Path is: %s \n", moduledata.module_name);
6000 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6001 zcm.init(true); //Load the module values.
6002 moduledata.refresh_title_screen = 1;
6003 // refresh_select_screen = 1;
6004 build_biic_list();
6005 return D_O_K;
6006 }
6007
6008 static DIALOG module_info_dlg[] =
6009 {
6010 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6011
6012
6013 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6014 //1
6015 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6016 //2
6017 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6018 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6019 //4
6020 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6021 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6022 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6023 //7
6024
6025 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6026 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6027 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6028 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6029 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6030 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6031 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6032 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6033 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6034
6035 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6036 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6037 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6038 };
6039
6040 void about_zcplayer_module(const char *prompt,int32_t initialval)
6041 {
6042
6043 module_info_dlg[0].dp2 = lfont;
6044 if ( moduledata.moduletitle[0] != 0 )
6045 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6046
6047 if ( moduledata.moduleauthor[0] != 0 )
6048 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6049
6050 if ( moduledata.moduleinfo0[0] != 0 )
6051 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6052 if ( moduledata.moduleinfo1[0] != 0 )
6053 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6054 if ( moduledata.moduleinfo2[0] != 0 )
6055 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6056 if ( moduledata.moduleinfo3[0] != 0 )
6057 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6058 if ( moduledata.moduleinfo4[0] != 0 )
6059 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6060
6061 char module_date[255];
6062 memset(module_date, 0, sizeof(module_date));
6063 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6064 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6065
6066
6067
6068 char module_vers[255];
6069 memset(module_vers, 0, sizeof(module_vers));
6070 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6071
6072
6073 //sprintf(tilecount,"%d",1);
6074
6075 char module_build[255];
6076 memset(module_build, 0, sizeof(module_build));
6077 if ( moduledata.modbeta )
6078 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6079 else
6080 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6081
6082 module_info_dlg[12].dp = (char*)module_date;
6083 module_info_dlg[13].dp = (char*)module_vers;
6084 module_info_dlg[14].dp = (char*)module_build;
6085
6086 large_dialog(module_info_dlg);
6087
6088 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6089 jwin_center_dialog(module_info_dlg);
6090
6091
6092 }
6093
6094 int32_t onAbout_ZCP_Module()
6095 {
6096 about_zcplayer_module("About Module (.zmod)", 0);
6097 return D_O_K;
6098 }
6099
6100 //New Modules Menu for 2.55+
6101 static MENU zcmodule_menu[] =
6102 {
6103 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6104 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6105
6106 { NULL, NULL, NULL, 0, NULL }
6107 };
6108
6109 int32_t onToggleRecordingNewSaves()
6110 {
6111 if (zc_get_config("zeldadx", "replay_new_saves", false))
6112 {
6113 zc_set_config("zeldadx", "replay_new_saves", false);
6114 }
6115 else
6116 {
6117 zc_set_config("zeldadx", "replay_new_saves", true);
6118 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6119 NULL,NULL,"OK",NULL,13,27,lfont);
6120 }
6121 return D_O_K;
6122 }
6123
6124 int32_t onToggleSnapshotAllFrames()
6125 {
6126 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6127 return D_O_K;
6128 }
6129
6130 int32_t onStopReplayOrRecord()
6131 {
6132 if (replay_is_replaying())
6133 {
6134 replay_quit();
6135 }
6136 else if (replay_get_mode() == ReplayMode::Record)
6137 {
6138 if (!replay_get_meta_bool("test_mode"))
6139 {
6140 jwin_alert("Recording", "You cannot stop recording a save file.",
6141 NULL,NULL,"OK",NULL,13,27,lfont);
6142 return D_CLOSE;
6143 }
6144
6145 if (jwin_alert("Stop Recording",
6146 "Save replay to disk and stop recording?",
6147 "This will stop the recording.",
6148 NULL,
6149 "Yes","No",13,27,lfont) != 1)
6150 return D_CLOSE;
6151
6152 replay_save();
6153 replay_stop();
6154 }
6155 return D_O_K;
6156 }
6157
6158 static int32_t handle_on_load_replay(ReplayMode mode)
6159 {
6160 if (Playing)
6161 {
6162 if (jwin_alert("Replay - Warning!",
6163 "Loading a replay will exit the current game.",
6164 "All unsaved progress will be lost.",
6165 "Do you wish to continue?",
6166 "Yes","No",13,27,lfont) != 1)
6167 return D_CLOSE;
6168 }
6169
6170 std::string mode_string = replay_mode_to_string(mode);
6171 mode_string[0] = std::toupper(mode_string[0]);
6172
6173 std::string line_1 = "Select a replay file to play back.";
6174 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6175 std::string line_3 = "You can stop the replay and take over manually any time.";
6176 if (mode == ReplayMode::Update)
6177 {
6178 line_1 = "Select a replay file to update.";
6179 line_2 = "WARNING: be sure to back up the zplay file";
6180 line_3 = "and verify that the updated replay works as expected!";
6181 }
6182
6183 if (jwin_alert(mode_string.c_str(),
6184 line_1.c_str(),
6185 line_2.c_str(),
6186 line_3.c_str(),
6187 "OK","Nevermind",13,27,lfont) == 1)
6188 {
6189 char replay_path[2048];
6190 strcpy(replay_path, "replays/");
6191 if (jwin_file_select_ex(
6192 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6193 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6194 return D_CLOSE;
6195
6196 replay_quit();
6197 load_replay_file_deferred(mode, replay_path);
6198 Quit = qRESET;
6199 return D_CLOSE;
6200 }
6201 return D_O_K;
6202 }
6203
6204 int32_t onLoadReplay()
6205 {
6206 return handle_on_load_replay(ReplayMode::Replay);
6207 }
6208
6209 int32_t onLoadReplayAssert()
6210 {
6211 return handle_on_load_replay(ReplayMode::Assert);
6212 }
6213
6214 int32_t onLoadReplayUpdate()
6215 {
6216 return handle_on_load_replay(ReplayMode::Update);
6217 }
6218
6219 int32_t onSaveReplay()
6220 {
6221 if (replay_get_mode() == ReplayMode::Record)
6222 {
6223 if (!replay_get_meta_bool("test_mode"))
6224 {
6225 if (jwin_alert("Save Replay",
6226 "This will save a copy of the replay up to this point.",
6227 "The official replay file will be untouched.",
6228 "Do you wish to continue?",
6229 "Yes","No",13,27,lfont) != 1)
6230 return D_CLOSE;
6231
6232 char replay_path[2048];
6233 strcpy(replay_path, replay_get_replay_path().string().c_str());
6234 if (jwin_file_select_ex(
6235 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6236 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6237 return D_CLOSE;
6238
6239 if (fileexists(replay_path))
6240 {
6241 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6242 NULL,NULL,"OK",NULL,13,27,lfont);
6243 return D_CLOSE;
6244 }
6245
6246 replay_save(replay_path);
6247 }
6248 else
6249 {
6250 replay_save();
6251 }
6252 }
6253 return D_O_K;
6254 }
6255
6256 static MENU replay_menu[] =
6257 {
6258 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6259 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6260 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6261 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6262 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6263 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6264 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6265
6266 { NULL, NULL, NULL, 0, NULL }
6267 };
6268
6269 static DIALOG credits_dlg[] =
6270 {
6271 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6272 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6273 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6274 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6275 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6276 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6277 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6278 };
6279
6280 29 static ListData dmap_list(dmaplist, &font);
6281
6282 static DIALOG goto_dlg[] =
6283 {
6284 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6285 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6286 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6287 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6288 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6289 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6290 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6291 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6292 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6293 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6294 };
6295
6296 int32_t onGoTo()
6297 {
6298 bool music = false;
6299 music = music;
6300 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6301
6302 goto_dlg[0].dp2=lfont;
6303 goto_dlg[4].d2=cheat_goto_dmap;
6304 goto_dlg[6].dp=cheat_goto_screen_str;
6305
6306 clear_keybuf();
6307
6308 large_dialog(goto_dlg);
6309
6310 if(zc_popup_dialog(goto_dlg,4)==1)
6311 {
6312 // dmap, screen
6313 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6314 };
6315
6316 return D_O_K;
6317 }
6318
6319 int32_t onGoToComplete()
6320 {
6321 if(!Playing)
6322 {
6323 return D_O_K;
6324 }
6325
6326 system_pal();
6327 music_pause();
6328 pause_all_sfx();
6329 onGoTo();
6330 eat_buttons();
6331
6332 zc_readrawkey(KEY_ESC);
6333
6334 game_pal();
6335 music_resume();
6336 resume_all_sfx();
6337 return D_O_K;
6338 }
6339
6340 int32_t onCredits()
6341 {
6342 go();
6343
6344 BITMAP *win = create_bitmap_ex(8,222,110);
6345
6346 if(!win)
6347 return D_O_K;
6348
6349 int32_t c=0;
6350 int32_t l=0;
6351 int32_t ol=-1;
6352 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6353 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6354 PALETTE tmppal;
6355
6356 rti_gui.transparency_index = 1;
6357
6358 clear_to_color(win, rti_gui.transparency_index);
6359 draw_rle_sprite(win,rle,0,0);
6360 credits_dlg[0].dp2=lfont;
6361 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6362 credits_dlg[2].dp = win;
6363
6364 zc_set_palette_range(black_palette,0,127,false);
6365
6366 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6367
6368 BITMAP* old_screen = screen;
6369 BITMAP* gui_bmp = zc_get_gui_bmp();
6370 ASSERT(gui_bmp);
6371 clear_to_color(gui_bmp, rti_gui.transparency_index);
6372 screen = gui_bmp;
6373
6374 while(update_dialog(p))
6375 {
6376 throttleFPS();
6377 ++c;
6378 l = zc_max((c>>1)-30,0);
6379
6380 if(l > rle->h)
6381 l = c = 0;
6382
6383 if(l > rle->h - 112)
6384 l = rle->h - 112;
6385
6386 clear_bitmap(win);
6387 draw_rle_sprite(win,rle,0,0-l);
6388
6389 if(c<=64)
6390 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6391
6392 zc_set_palette_range(tmppal,0,127,false);
6393
6394 if(l!=ol)
6395 {
6396 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6397 SCRFIX();
6398 ol=l;
6399 }
6400
6401 update_hw_screen();
6402 }
6403
6404 screen = old_screen;
6405 system_pal();
6406
6407 shutdown_dialog(p);
6408 destroy_bitmap(win);
6409 //comeback();
6410
6411 rti_gui.transparency_index = 0;
6412
6413 return D_O_K;
6414 }
6415
6416 const char *midilist(int32_t index, int32_t *list_size)
6417 {
6418 if(index<0)
6419 {
6420 *list_size=0;
6421
6422 for(int32_t i=0; i<MAXMIDIS; i++)
6423 if(tunes[i].data)
6424 ++(*list_size);
6425
6426 return NULL;
6427 }
6428
6429 int32_t i=0,m=0;
6430
6431 while(m<=index && i<=MAXMIDIS)
6432 {
6433 if(tunes[i].data)
6434 ++m;
6435
6436 ++i;
6437 }
6438
6439 --i;
6440
6441 if(i==MAXMIDIS && m<index)
6442 return "(null)";
6443
6444 return tunes[i].title;
6445 }
6446
6447 /* ------- MIDI info stuff -------- */
6448
6449 char *text;
6450 midi_info *zmi;
6451 bool dialog_running;
6452 bool listening;
6453
6454 void get_info(int32_t index);
6455
6456 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6457 {
6458 int32_t d2 = d->d2;
6459 int32_t ret = jwin_droplist_proc(msg,d,c);
6460
6461 if(d2!=d->d2)
6462 {
6463 get_info(d->d2);
6464 }
6465
6466 return ret;
6467 }
6468
6469 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6470 {
6471 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6472
6473 int32_t ret = jwin_button_proc(msg,d,c);
6474
6475 if(ret == D_CLOSE)
6476 {
6477 // get current midi index
6478 int32_t index = (d+(d->d1))->d2;
6479 int32_t i=0, m=0;
6480
6481 while(m<=index && i<=MAXMIDIS)
6482 {
6483 if(tunes[i].data)
6484 ++m;
6485
6486 ++i;
6487 }
6488
6489 --i;
6490 jukebox(i);
6491 listening = true;
6492 ret = D_O_K;
6493 }
6494
6495 return ret;
6496 }
6497
6498 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6499 {
6500 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6501
6502 int32_t ret = jwin_button_proc(msg,d,c);
6503
6504 if(ret == D_CLOSE)
6505 {
6506 // get current midi index
6507 int32_t index = (d+(d->d1))->d2;
6508 int32_t i=0, m=0;
6509
6510 while(m<=index && i<=MAXMIDIS)
6511 {
6512 if(tunes[i].data)
6513 ++m;
6514
6515 ++i;
6516 }
6517
6518 --i;
6519
6520 // get file name
6521
6522 int32_t sel=0;
6523 //struct ffblk f;
6524 char title[40] = "Save MIDI: ";
6525 char fname[2048];
6526 memset(fname,0,2048);
6527 static EXT_LIST list[] =
6528 {
6529 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6530 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6531 { NULL, NULL }
6532 };
6533
6534 strcpy(title+11, tunes[i].title);
6535 title[39] = '\0';
6536
6537 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6538 goto done;
6539
6540 if(exists(fname))
6541 {
6542 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6543 goto done;
6544 }
6545
6546 // save midi i
6547
6548 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6549 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6550
6551 done:
6552 chop_path(fname);
6553 ret = D_REDRAW;
6554 }
6555
6556 return ret;
6557 }
6558
6559 29 static ListData midi_list(midilist, &font);
6560
6561 static DIALOG midi_dlg[] =
6562 {
6563 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6564 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6565 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6566 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6567 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6568 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6569 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6570 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6571 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6572 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6573 };
6574
6575 void get_info(int32_t index)
6576 {
6577 int32_t i=0, m=0;
6578
6579 while(m<=index && i<=MAXMIDIS)
6580 {
6581 if(tunes[i].data)
6582 ++m;
6583
6584 ++i;
6585 }
6586
6587 --i;
6588
6589 if(i==MAXMIDIS && m<index)
6590 strcpy(text,"(null)");
6591 else
6592 {
6593 get_midi_info((MIDI*)tunes[i].data,zmi);
6594 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6595 }
6596
6597 midi_dlg[0].dp2=lfont;
6598 midi_dlg[3].dp = text;
6599 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6600 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6601
6602 if(dialog_running)
6603 {
6604 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6605 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6606 }
6607 }
6608
6609 int32_t onMIDICredits()
6610 {
6611 text = (char*)malloc(4096);
6612 zmi = (midi_info*)malloc(sizeof(midi_info));
6613
6614 if(!text || !zmi)
6615 {
6616 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6617 return D_O_K;
6618 }
6619
6620 bool do_pause_midi = midi_pos >= 0 && currmidi;
6621 auto restore_midi = currmidi;
6622 if(do_pause_midi)
6623 {
6624 paused_midi_pos = midi_pos;
6625 stop_midi();
6626 midi_paused=true;
6627 midi_suspended = midissuspHALTED;
6628 }
6629
6630 midi_dlg[0].dp2=lfont;
6631 midi_dlg[2].d1 = 0;
6632 midi_dlg[2].d2 = 0;
6633 midi_dlg[4].flags = D_EXIT;
6634 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6635
6636 listening = false;
6637 dialog_running=false;
6638 get_info(0);
6639
6640 dialog_running=true;
6641
6642 large_dialog(midi_dlg);
6643
6644 zc_popup_dialog(midi_dlg,0);
6645 dialog_running=false;
6646
6647 if(listening)
6648 music_stop();
6649
6650 if(do_pause_midi)
6651 {
6652 midi_suspended = midissuspRESUME;
6653 currmidi = restore_midi;
6654 midi_pos = paused_midi_pos;
6655 }
6656
6657 if(text) free(text);
6658 if(zmi) free(zmi);
6659 return D_O_K;
6660 }
6661
6662 int32_t onAbout()
6663 {
6664 char buf1[80]={0};
6665 std::ostringstream oss;
6666 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6667 oss << buf1 << '\n';
6668 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6669 oss << buf1 << '\n';
6670 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6671 oss << buf1 << '\n';
6672 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6673 oss << buf1 << '\n';
6674 sprintf(buf1, "Tag: %s", getReleaseTag());
6675 oss << buf1 << '\n';
6676
6677 InfoDialog("About ZC", oss.str()).show();
6678 return D_O_K;
6679 }
6680
6681 int32_t onQuest()
6682 {
6683 char fname[100];
6684 strcpy(fname, get_filename(qstpath));
6685 quest_dlg[0].dp2=lfont;
6686 quest_dlg[1].dp = fname;
6687
6688 if(QHeader.quest_number==0)
6689 sprintf(str_a,"Custom");
6690 else
6691 sprintf(str_a,"%d",QHeader.quest_number);
6692
6693 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6694
6695 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6696 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6697
6698 large_dialog(quest_dlg);
6699
6700 zc_popup_dialog(quest_dlg, 0);
6701 return D_O_K;
6702 }
6703
6704 void call_vidmode_dlg();
6705 int32_t onVidMode()
6706 {
6707 call_vidmode_dlg();
6708 return D_O_K;
6709 }
6710
6711 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6712 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6713 //Added an extra statement, so that if the key is cleared to 0, the cleared
6714 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6715
6716 void load_ukeys(int32_t* arr)
6717 {
6718 arr[ukey_a] = Akey;
6719 arr[ukey_b] = Bkey;
6720 arr[ukey_s] = Skey;
6721 arr[ukey_l] = Lkey;
6722 arr[ukey_r] = Rkey;
6723 arr[ukey_p] = Pkey;
6724 arr[ukey_ex1] = Exkey1;
6725 arr[ukey_ex2] = Exkey2;
6726 arr[ukey_ex3] = Exkey3;
6727 arr[ukey_ex4] = Exkey4;
6728 arr[ukey_du] = DUkey;
6729 arr[ukey_dd] = DDkey;
6730 arr[ukey_dl] = DLkey;
6731 arr[ukey_dr] = DRkey;
6732 arr[ukey_mod1a] = cheat_modifier_keys[0];
6733 arr[ukey_mod1b] = cheat_modifier_keys[1];
6734 arr[ukey_mod2a] = cheat_modifier_keys[2];
6735 arr[ukey_mod2b] = cheat_modifier_keys[3];
6736 };
6737
6738 static const char* ukey_names[] = {
6739 "A", "B", "Start", "L", "R", "Map",
6740 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6741 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6742 "Cheat Mod R1", "Cheat Mod R2",
6743 };
6744 std::string get_ukey_name(int32_t k)
6745 {
6746 if (k < num_ukey) return ukey_names[k];
6747 return "";
6748 }
6749
6750 int32_t onKeyboard()
6751 {
6752 int32_t a = Akey;
6753 int32_t b = Bkey;
6754 int32_t s = Skey;
6755 int32_t l = Lkey;
6756 int32_t r = Rkey;
6757 int32_t p = Pkey;
6758 int32_t ex1 = Exkey1;
6759 int32_t ex2 = Exkey2;
6760 int32_t ex3 = Exkey3;
6761 int32_t ex4 = Exkey4;
6762 int32_t du = DUkey;
6763 int32_t dd = DDkey;
6764 int32_t dl = DLkey;
6765 int32_t dr = DRkey;
6766 int32_t mod1a = cheat_modifier_keys[0];
6767 int32_t mod1b = cheat_modifier_keys[1];
6768 int32_t mod2a = cheat_modifier_keys[2];
6769 int32_t mod2b = cheat_modifier_keys[3];
6770 bool done=false;
6771 int32_t ret;
6772
6773 keyboard_control_dlg[0].dp2=lfont;
6774
6775 large_dialog(keyboard_control_dlg);
6776
6777 while(!done)
6778 {
6779 ret = zc_popup_dialog(keyboard_control_dlg,3);
6780
6781 if(ret==3) // OK
6782 {
6783 int32_t ukeys[num_ukey];
6784 load_ukeys(ukeys);
6785 std::vector<std::string> uniqueError;
6786 for(int32_t q = 0; q < num_ukey; ++q)
6787 {
6788 for(int32_t p = q+1; p < num_ukey; ++p)
6789 {
6790 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6791 {
6792 char buf[64];
6793 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6794 std::string str(buf);
6795 uniqueError.push_back(str);
6796 }
6797 }
6798 }
6799 if(uniqueError.size() == 0)
6800 {
6801 done = true;
6802 save_control_configs(true);
6803 }
6804 else
6805 {
6806 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6807 box_out("Cannot have duplicate keybinds!"); box_eol();
6808 for(std::vector<std::string>::iterator it = uniqueError.begin();
6809 it != uniqueError.end(); ++it)
6810 {
6811 box_out((*it).c_str()); box_eol();
6812 }
6813 box_end(true);
6814 }
6815 }
6816 else // Cancel
6817 {
6818 Akey = a;
6819 Bkey = b;
6820 Skey = s;
6821 Lkey = l;
6822 Rkey = r;
6823 Pkey = p;
6824 Exkey1 = ex1;
6825 Exkey2 = ex2;
6826 Exkey3 = ex3;
6827 Exkey4 = ex4;
6828 DUkey = du;
6829 DDkey = dd;
6830 DLkey = dl;
6831 DRkey = dr;
6832 cheat_modifier_keys[0] = mod1a;
6833 cheat_modifier_keys[1] = mod1b;
6834 cheat_modifier_keys[2] = mod2a;
6835 cheat_modifier_keys[3] = mod2b;
6836
6837 done=true;
6838 }
6839
6840 rest(1);
6841 }
6842
6843 return D_O_K;
6844 }
6845
6846 int32_t onGamepad()
6847 {
6848 int32_t a = Abtn;
6849 int32_t b = Bbtn;
6850 int32_t s = Sbtn;
6851 int32_t l = Lbtn;
6852 int32_t r = Rbtn;
6853 int32_t m = Mbtn;
6854 int32_t p = Pbtn;
6855 int32_t ex1 = Exbtn1;
6856 int32_t ex2 = Exbtn2;
6857 int32_t ex3 = Exbtn3;
6858 int32_t ex4 = Exbtn4;
6859 int32_t up = DUbtn;
6860 int32_t down = DDbtn;
6861 int32_t left = DLbtn;
6862 int32_t right = DRbtn;
6863
6864 gamepad_dlg[0].dp2=lfont;
6865 if(analog_movement)
6866 gamepad_dlg[56].flags|=D_SELECTED;
6867 else
6868 gamepad_dlg[56].flags&=~D_SELECTED;
6869
6870 large_dialog(gamepad_dlg);
6871
6872 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6873
6874 if(ret == 4) //OK
6875 {
6876 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6877 save_control_configs(false);
6878 }
6879 else //Cancel
6880 {
6881 Abtn = a;
6882 Bbtn = b;
6883 Sbtn = s;
6884 Lbtn = l;
6885 Rbtn = r;
6886 Mbtn = m;
6887 Pbtn = p;
6888 Exbtn1 = ex1;
6889 Exbtn2 = ex2;
6890 Exbtn3 = ex3;
6891 Exbtn4 = ex4;
6892 DUbtn = up;
6893 DDbtn = down;
6894 DLbtn = left;
6895 DRbtn = right;
6896 }
6897
6898 return D_O_K;
6899 }
6900
6901 int32_t onCheatKeys()
6902 {
6903 int32_t oldcheats[Cheat::Last][2];
6904 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6905
6906 bool done=false;
6907
6908 while(!done)
6909 {
6910 bool confirm = false;
6911 CheatKeysDialog(&confirm).show();
6912 if(confirm) // OK
6913 {
6914 std::vector<std::string> uniqueError;
6915 char buf[512];
6916 for(size_t q = 1; q < Cheat::Last; ++q)
6917 {
6918 if(cheatkeys[q][1] && !cheatkeys[q][0])
6919 {
6920 cheatkeys[q][0] = cheatkeys[q][1];
6921 cheatkeys[q][1] = 0;
6922 }
6923 }
6924 for(size_t q = 1; q < Cheat::Last; ++q)
6925 {
6926 if(!bindable_cheat((Cheat)q)) continue;
6927 for(size_t p = q+1; p < Cheat::Last; ++p)
6928 {
6929 if(!bindable_cheat((Cheat)p)) continue;
6930 for(size_t q2 = 0; q2 <= 1; ++q2)
6931 for(size_t p2 = 0; p2 <= 1; ++p2)
6932 {
6933 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6934 {
6935 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6936 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6937 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6938 get_keystr(cheatkeys[q][q2])));
6939 }
6940 }
6941 }
6942 }
6943 if(uniqueError.size() == 0)
6944 {
6945 done = true;
6946 save_cheatkeys();
6947 }
6948 else
6949 {
6950 box_start(1, "Duplicate Keys", lfont, sfont, false, 500,400, 2);
6951 box_out("Cannot have duplicate keybinds!"); box_eol();
6952 for(std::vector<std::string>::iterator it = uniqueError.begin();
6953 it != uniqueError.end(); ++it)
6954 {
6955 box_out((*it).c_str()); box_eol();
6956 }
6957 box_end(true);
6958 }
6959 }
6960 else // Cancel
6961 {
6962 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6963 done=true;
6964 }
6965 rest(1);
6966 }
6967
6968 return D_O_K;
6969 }
6970
6971 int32_t onSound()
6972 {
6973 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
6974 {
6975 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
6976 }
6977 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
6978 {
6979 master_volume((int32_t)(FFCore.usr_digi_volume),1);
6980 }
6981 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
6982 {
6983 emusic_volume = (int32_t)FFCore.usr_music_volume;
6984 }
6985 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
6986 {
6987 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6988 }
6989 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6990 {
6991 pan_style = (int32_t)FFCore.usr_panstyle;
6992 }
6993
6994 int32_t m = midi_volume;
6995 int32_t d = digi_volume;
6996 int32_t e = emusic_volume;
6997 int32_t b = zcmusic_bufsz;
6998 int32_t s = sfx_volume;
6999 int32_t p = pan_style;
7000 pan_style = vbound(pan_style,0,3);
7001
7002 sound_dlg[0].dp2=lfont;
7003
7004 large_dialog(sound_dlg);
7005
7006 midi_dp[1] = sound_dlg[6].x;
7007 midi_dp[2] = sound_dlg[6].y;
7008 digi_dp[1] = sound_dlg[7].x;
7009 digi_dp[2] = sound_dlg[7].y;
7010 emus_dp[1] = sound_dlg[8].x;
7011 emus_dp[2] = sound_dlg[8].y;
7012 buf_dp[1] = sound_dlg[9].x;
7013 buf_dp[2] = sound_dlg[9].y;
7014 sfx_dp[1] = sound_dlg[10].x;
7015 sfx_dp[2] = sound_dlg[10].y;
7016 pan_dp[1] = sound_dlg[11].x;
7017 pan_dp[2] = sound_dlg[11].y;
7018 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7019 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7020 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7021 sound_dlg[18].d2 = zcmusic_bufsz;
7022 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7023 sound_dlg[20].d2 = pan_style;
7024
7025 int32_t ret = zc_popup_dialog(sound_dlg,1);
7026
7027 if(ret==2)
7028 {
7029 master_volume(digi_volume,midi_volume);
7030
7031 for(int32_t i=0; i<WAV_COUNT; ++i)
7032 {
7033 //allegro assertion fails when passing in -1 as voice -DD
7034 if(sfx_voice[i] > 0)
7035 voice_set_volume(sfx_voice[i], sfx_volume);
7036 }
7037 zc_set_config(sfx_sect,"digi",digi_volume);
7038 zc_set_config(sfx_sect,"midi",midi_volume);
7039 zc_set_config(sfx_sect,"sfx",sfx_volume);
7040 zc_set_config(sfx_sect,"emusic",emusic_volume);
7041 zc_set_config(sfx_sect,"pan",pan_style);
7042 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7043 }
7044 else
7045 {
7046 midi_volume = m;
7047 digi_volume = d;
7048 emusic_volume = e;
7049 zcmusic_bufsz = b;
7050 sfx_volume = s;
7051 pan_style = p;
7052 }
7053
7054 return D_O_K;
7055 }
7056
7057 int32_t queding(char const* s1, char const* s2, char const* s3)
7058 {
7059 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7060 }
7061
7062 int32_t onQuit()
7063 {
7064 if(Playing)
7065 {
7066 int32_t ret=0;
7067
7068 if(get_bit(quest_rules, qr_NOCONTINUE))
7069 {
7070 if(standalone_mode)
7071 {
7072 ret=queding("End current game?",
7073 "The continue screen is disabled; the game",
7074 "will be reloaded from the last save.");
7075 }
7076 else
7077 {
7078 ret=queding("End current game?",
7079 "The continue screen is disabled. You will",
7080 "be returned to the file select screen.");
7081 }
7082 }
7083 else
7084 ret=queding("End current game?",NULL,NULL);
7085
7086 if(ret==1)
7087 {
7088 disableClickToFreeze=false;
7089 Quit=qQUIT;
7090
7091 // Trying to evade a door repair charge?
7092 if(repaircharge)
7093 {
7094 game->change_drupy(-repaircharge);
7095 repaircharge=0;
7096 }
7097
7098 return D_CLOSE;
7099 }
7100 }
7101
7102 return D_O_K;
7103 }
7104
7105 int32_t onTryQuitMenu()
7106 {
7107 return onTryQuit(true);
7108 }
7109
7110 int32_t onTryQuit(bool inMenu)
7111 {
7112 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7113 {
7114 if(get_bit(quest_rules,qr_OLD_F6))
7115 {
7116 if(inMenu) onQuit();
7117 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7118 }
7119 else
7120 {
7121 disableClickToFreeze=false;
7122 GameFlags |= GAMEFLAG_TRYQUIT;
7123 }
7124 return D_CLOSE;
7125 }
7126
7127 return D_O_K;
7128 }
7129
7130 int32_t onReset()
7131 {
7132 if(queding(" Reset system? ",NULL,NULL)==1)
7133 {
7134 disableClickToFreeze=false;
7135 Quit=qRESET;
7136 replay_quit();
7137 return D_CLOSE;
7138 }
7139
7140 return D_O_K;
7141 }
7142
7143 int32_t onExit()
7144 {
7145 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7146 {
7147 Quit=qEXIT;
7148 return D_CLOSE;
7149 }
7150
7151 return D_O_K;
7152 }
7153
7154 int32_t onTitle_NES()
7155 {
7156 title_version=0;
7157 zc_set_config(cfg_sect,"title",title_version);
7158 return D_O_K;
7159 }
7160 int32_t onTitle_DX()
7161 {
7162 title_version=1;
7163 zc_set_config(cfg_sect,"title",title_version);
7164 return D_O_K;
7165 }
7166 int32_t onTitle_25()
7167 {
7168 title_version=2;
7169 zc_set_config(cfg_sect,"title",title_version);
7170 return D_O_K;
7171 }
7172
7173 int32_t onDebug()
7174 {
7175 if(debug_enabled)
7176 set_debug(!get_debug());
7177 return D_O_K;
7178 }
7179
7180 int32_t onHeartBeep()
7181 {
7182 heart_beep=!heart_beep;
7183 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7184 return D_O_K;
7185 }
7186
7187 int32_t onSaveIndicator()
7188 {
7189 use_save_indicator=!use_save_indicator;
7190 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7191 return D_O_K;
7192 }
7193
7194 int32_t onEpilepsy()
7195 {
7196 if(jwin_alert3(
7197 "Epilepsy Flash Reduction",
7198 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7199 "Disabling this will restore standard flash and wavy behaviour.",
7200 "Proceed?",
7201 "&Yes",
7202 "&No",
7203 NULL,
7204 'y',
7205 'n',
7206 0,
7207 lfont) == 1)
7208 {
7209 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7210 zc_set_config("zeldadx","checked_epilepsy",1);
7211 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7212 }
7213 return D_O_K;
7214 }
7215
7216 int32_t onTriforce()
7217 {
7218 for(int32_t i=0; i<MAXINITTABS; ++i)
7219 {
7220 init_tabs[i].flags&=~D_SELECTED;
7221 }
7222
7223 init_tabs[3].flags=D_SELECTED;
7224 return onCheatConsole();
7225 /*triforce_dlg[0].dp2=lfont;
7226 for(int32_t i=1; i<=8; i++)
7227 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7228
7229 if(zc_popup_dialog (triforce_dlg,-1)==9)
7230 {
7231 for(int32_t i=1; i<=8; i++)
7232 {
7233 game->lvlitems[i] &= ~liTRIFORCE;
7234 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7235 }
7236 }
7237 return D_O_K;*/
7238 }
7239
7240 bool rc = false;
7241 /*
7242 int32_t onEquipment()
7243 {
7244 for (int32_t i=0; i<MAXINITTABS; ++i)
7245 {
7246 init_tabs[i].flags&=~D_SELECTED;
7247 }
7248 init_tabs[0].flags=D_SELECTED;
7249 return onCheatConsole();
7250 }
7251 */
7252
7253 int32_t onItems()
7254 {
7255 for(int32_t i=0; i<MAXINITTABS; ++i)
7256 {
7257 init_tabs[i].flags&=~D_SELECTED;
7258 }
7259
7260 init_tabs[1].flags=D_SELECTED;
7261 return onCheatConsole();
7262 }
7263
7264 static DIALOG getnum_dlg[] =
7265 {
7266 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7267 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7268 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7269 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7270 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7271 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7272 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7273 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7274 };
7275
7276 int32_t getnumber(const char *prompt,int32_t initialval)
7277 {
7278 char buf[20];
7279 sprintf(buf,"%d",initialval);
7280 getnum_dlg[0].dp=(void *)prompt;
7281 getnum_dlg[0].dp2=lfont;
7282 getnum_dlg[2].dp=buf;
7283
7284 large_dialog(getnum_dlg);
7285
7286 if(zc_popup_dialog(getnum_dlg,2)==3)
7287 return atoi(buf);
7288
7289 return initialval;
7290 }
7291
7292 int32_t onLife()
7293 {
7294 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7295 cheats_enqueue(Cheat::Life, value);
7296 return D_O_K;
7297 }
7298
7299 int32_t onHeartC()
7300 {
7301 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7302 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7303 cheats_enqueue(Cheat::MaxLife, max_life);
7304 cheats_enqueue(Cheat::Life, life);
7305 return D_O_K;
7306 }
7307
7308 int32_t onMagicC()
7309 {
7310 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7311 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7312 cheats_enqueue(Cheat::MaxMagic, max_magic);
7313 cheats_enqueue(Cheat::Magic, magic);
7314 return D_O_K;
7315 }
7316
7317 int32_t onRupies()
7318 {
7319 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7320 cheats_enqueue(Cheat::Rupies, value);
7321 return D_O_K;
7322 }
7323
7324 int32_t onMaxBombs()
7325 {
7326 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7327 cheats_enqueue(Cheat::MaxBombs, value);
7328 cheats_enqueue(Cheat::Bombs, value);
7329 return D_O_K;
7330 }
7331
7332 int32_t onRefillLife()
7333 {
7334 cheats_enqueue(Cheat::Life, game->get_maxlife());
7335 return D_O_K;
7336 }
7337 int32_t onRefillMagic()
7338 {
7339 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7340 return D_O_K;
7341 }
7342 int32_t onClock()
7343 {
7344 cheats_enqueue(Cheat::Clock);
7345 return D_O_K;
7346 }
7347
7348 int32_t onQstPath()
7349 {
7350 char path[2048];
7351
7352 chop_path(qstdir);
7353 strcpy(path,qstdir);
7354
7355 go();
7356
7357 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7358 {
7359 chop_path(path);
7360 fix_filename_case(path);
7361 fix_filename_slashes(path);
7362 strcpy(qstdir,path);
7363 strcpy(qstpath,qstdir);
7364 }
7365
7366 comeback();
7367 return D_O_K;
7368 }
7369
7370 #include "dialog/cheat_dialog.h"
7371 int32_t onCheat()
7372 {
7373 call_setcheat_dialog();
7374 game->set_cheat(maxcheat);
7375 if(cheat) game->did_cheat(true);
7376 return D_O_K;
7377 }
7378
7379 int32_t onCheatRupies()
7380 {
7381 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7382 return D_O_K;
7383 }
7384
7385 int32_t onCheatArrows()
7386 {
7387 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7388 return D_O_K;
7389 }
7390
7391 int32_t onCheatBombs()
7392 {
7393 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7394 return D_O_K;
7395 }
7396
7397 // *** screen saver
7398
7399 6510614 int32_t after_time()
7400 {
7401
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(ss_enable == 0)
7402 return INT_MAX;
7403
7404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 0)
7405 return 5 * 60;
7406
7407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 3)
7408 return ss_after * 15 * 60;
7409
7410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 13)
7411 return (ss_after - 3) * 60 * 60;
7412
7413 6510614 return MAX_IDLE + 1;
7414 6510614 }
7415
7416 static const char *after_str[15] =
7417 {
7418 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7419 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7420 "Never"
7421 };
7422
7423 const char *after_list(int32_t index, int32_t *list_size)
7424 {
7425 if(index < 0)
7426 {
7427 *list_size = 15;
7428 return NULL;
7429 }
7430
7431 return after_str[index];
7432 }
7433
7434 29 static ListData after__list(after_list, &font);
7435
7436 static DIALOG scrsaver_dlg[] =
7437 {
7438 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7439 29 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7440 29 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7441 29 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7442 29 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7443 29 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7444 29 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7445 29 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7446 29 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7447 29 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7448 29 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7449 29 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7450 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7451 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7452 };
7453
7454 int32_t onScreenSaver()
7455 {
7456 scrsaver_dlg[0].dp2=lfont;
7457 int32_t oldcfgs[3];
7458 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7459 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7460 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7461
7462 large_dialog(scrsaver_dlg);
7463
7464 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7465
7466 if(ret == 8 || ret == 9)
7467 {
7468 ss_after = scrsaver_dlg[5].d1;
7469 ss_speed = scrsaver_dlg[6].d2;
7470 ss_density = scrsaver_dlg[7].d2;
7471 if(oldcfgs[0] != ss_after)
7472 zc_set_config(cfg_sect,"ss_after",ss_after);
7473 if(oldcfgs[1] != ss_speed)
7474 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7475 if(oldcfgs[2] != ss_density)
7476 zc_set_config(cfg_sect,"ss_density",ss_density);
7477 }
7478
7479 if(ret == 9)
7480 // preview Screen Saver
7481 {
7482 clear_keybuf();
7483 Matrix(ss_speed, ss_density, 30);
7484 system_pal();
7485 }
7486
7487 return D_O_K;
7488 }
7489
7490 /***** Menus *****/
7491
7492 static MENU game_menu[] =
7493 {
7494 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7495 { (char *)"", NULL, NULL, 0, NULL },
7496 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7497 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7498 { (char *)"", NULL, NULL, 0, NULL },
7499 #ifdef __EMSCRIPTEN__
7500 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7501 #elif defined(ALLEGRO_MACOSX)
7502 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7503 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7504 #else
7505 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7506 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7507 #endif
7508 { NULL, NULL, NULL, 0, NULL }
7509 };
7510
7511 static MENU title_menu[] =
7512 {
7513 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7514 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7515 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7516 { NULL, NULL, NULL, 0, NULL }
7517 };
7518
7519 static MENU snapshot_format_menu[] =
7520 {
7521 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7522 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7523 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7524 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7525 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7526 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7527 { NULL, NULL, NULL, 0, NULL }
7528 };
7529
7530 static MENU controls_menu[] =
7531 {
7532 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7533 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7534 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7535 { NULL, NULL, NULL, 0, NULL }
7536 };
7537
7538 static MENU name_entry_mode_menu[] =
7539 {
7540 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7541 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7542 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7543 { NULL, NULL, NULL, 0, NULL }
7544 };
7545
7546 static void set_controls_menu_active()
7547 {
7548
7549 }
7550
7551 static MENU window_menu[] =
7552 {
7553 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7554 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7555 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7556 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7557 { NULL, NULL, NULL, 0, NULL }
7558 };
7559 static MENU options_menu[] =
7560 {
7561 { "&Title Screen", NULL, title_menu, 0, NULL },
7562 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7563 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7564 { "&Window Settings", NULL, window_menu, 0, NULL },
7565 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7566 { "Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7567 { NULL, NULL, NULL, 0, NULL }
7568 };
7569 static MENU settings_menu[] =
7570 {
7571 { "&Sound...", onSound, NULL, 0, NULL },
7572 { "C&ontrols", NULL, controls_menu, 0, NULL },
7573 { "", NULL, NULL, 0, NULL },
7574 { "Options", NULL, options_menu, 0, NULL },
7575 { "", NULL, NULL, 0, NULL },
7576 //
7577 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7578 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7579 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7580 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7581 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7582 //
7583 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7584 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7585 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7586 { "", NULL, NULL, 0, NULL },
7587 { "Debu&g", onDebug, NULL, 0, NULL },
7588 //
7589 { NULL, NULL, NULL, 0, NULL }
7590 };
7591
7592
7593 static MENU misc_menu[] =
7594 {
7595 { (char *)"&About...", onAbout, NULL, 0, NULL },
7596 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7597 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7598 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7599 { (char *)"", NULL, NULL, 0, NULL },
7600 //5
7601 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7602 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7603 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7604 { (char *)"", NULL, NULL, 0, NULL },
7605 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7606 //10
7607 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7608 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7609 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7610 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7611 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7612 //15
7613 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7614 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7615 { NULL, NULL, NULL, 0, NULL }
7616 };
7617
7618 static MENU refill_menu[] =
7619 {
7620 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7621 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7622 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7623 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7624 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7625 { NULL, NULL, NULL, 0, NULL }
7626 };
7627
7628 static MENU show_menu[] =
7629 {
7630 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7631 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7632 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7633 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7634 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7635 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7636 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7637 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7638 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7639 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7640 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7641 { (char *)"", NULL, NULL, 0, NULL },
7642 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7643 { (char *)"", NULL, NULL, 0, NULL },
7644 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7645 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7646 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7647 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7648 { NULL, NULL, NULL, 0, NULL }
7649 };
7650
7651 static MENU cheat_menu[] =
7652 {
7653 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7654 { (char *)"", NULL, NULL, 0, NULL },
7655 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7656 { (char *)"", NULL, NULL, 0, NULL },
7657 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7658 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7659 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7660 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7661 { (char *)"", NULL, NULL, 0, NULL },
7662 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7663 { (char *)"", NULL, NULL, 0, NULL },
7664 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7665 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7666 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7667 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7668 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7669 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7670 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7671 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7672 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7673 { NULL, NULL, NULL, 0, NULL }
7674 };
7675
7676 #if DEVLEVEL > 0
7677 int32_t devLogging();
7678 int32_t devDebug();
7679 int32_t devTimestmp();
7680 #if DEVLEVEL > 1
7681 int32_t setCheat();
7682 #endif //DEVLEVEL > 1
7683 enum
7684 {
7685 dv_log,
7686 // dv_dbg,
7687 dv_tmpstmp,
7688 #if DEVLEVEL > 1
7689 dv_nil,
7690 dv_setcheat,
7691 #endif //DEVLEVEL > 1
7692 dv_max
7693 };
7694 static MENU dev_menu[] =
7695 {
7696 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7697 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7698 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7699 #if DEVLEVEL > 1
7700 { (char *)"", NULL, NULL, 0, NULL },
7701 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7702 #endif //DEVLEVEL > 1
7703 { NULL, NULL, NULL, 0, NULL }
7704 };
7705 int32_t devLogging()
7706 {
7707 dev_logging = !dev_logging;
7708 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7709 return D_O_K;
7710 }
7711 // int32_t devDebug()
7712 // {
7713 // dev_debug = !dev_debug;
7714 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7715 // return D_O_K;
7716 // }
7717 int32_t devTimestmp()
7718 {
7719 dev_timestmp = !dev_timestmp;
7720 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7721 return D_O_K;
7722 }
7723 #if DEVLEVEL > 1
7724 int32_t setCheat()
7725 {
7726 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7727 return D_O_K;
7728 }
7729 #endif //DEVLEVEL > 1
7730 #endif //DEVLEVEL > 0
7731
7732 MENU the_player_menu[] =
7733 {
7734 { (char *)"&Game", NULL, game_menu, 0, NULL },
7735 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7736 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7737 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7738 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7739 #if DEVLEVEL > 0
7740 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7741 #endif
7742 { NULL, NULL, NULL, 0, NULL }
7743 };
7744 int32_t onMIDIPatch()
7745 {
7746 if(jwin_alert3(
7747 "Toggle Windows MIDI Fix",
7748 "This action will change whether ZC Player auto-restarts a MIDI at its",
7749 "last index if you move ZC Player out of focus, then back into focus.",
7750 "Proceed?",
7751 "&Yes",
7752 "&No",
7753 NULL,
7754 'y',
7755 'n',
7756 0,
7757 lfont) == 1)
7758 {
7759 midi_patch_fix = midi_patch_fix ? 0 : 1;
7760 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7761 }
7762 options_menu[5].flags =(midi_patch_fix)?D_SELECTED:0;
7763 return D_O_K;
7764 }
7765
7766 int32_t onKeyboardEntry()
7767 {
7768 NameEntryMode=0;
7769 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7770 return D_O_K;
7771 }
7772
7773 int32_t onLetterGridEntry()
7774 {
7775 NameEntryMode=1;
7776 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7777 return D_O_K;
7778 }
7779
7780 int32_t onExtLetterGridEntry()
7781 {
7782 NameEntryMode=2;
7783 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7784 return D_O_K;
7785 }
7786
7787 static BITMAP* oldscreen;
7788 int32_t onFullscreenMenu()
7789 {
7790 // super hacks
7791 screen = oldscreen;
7792 if (onFullscreen() == D_REDRAW)
7793 {
7794 oldscreen = screen;
7795 }
7796 screen = menu_bmp;
7797 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7798 return D_O_K;
7799 }
7800
7801 29 void fix_menu()
7802 {
7803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!debug_enabled)
7804 29 settings_menu[13].text = NULL;
7805 29 }
7806
7807 static DIALOG system_dlg[] =
7808 {
7809 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7810 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7811 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7812 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7813 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7814 #ifndef ALLEGRO_MACOSX
7815 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7816 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7817 #else
7818 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7819 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7820 #endif
7821 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7822 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7823 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7824 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7825 };
7826
7827 void reset_snapshot_format_menu()
7828 {
7829 for(int32_t i=0; i<ssfmtMAX; ++i)
7830 {
7831 snapshot_format_menu[i].flags=0;
7832 }
7833 }
7834
7835 int32_t onSetSnapshotFormat()
7836 {
7837 switch(active_menu->text[1])
7838 {
7839 case 'B': //"&BMP"
7840 SnapshotFormat=0;
7841 break;
7842
7843 case 'G': //"&GIF"
7844 SnapshotFormat=1;
7845 break;
7846
7847 case 'J': //"&JPG"
7848 SnapshotFormat=2;
7849 break;
7850
7851 case 'P': //"&PNG"
7852 SnapshotFormat=3;
7853 break;
7854
7855 case 'C': //"PC&X"
7856 SnapshotFormat=4;
7857 break;
7858
7859 case 'T': //"&TGA"
7860 SnapshotFormat=5;
7861 break;
7862
7863 case 'L': //"&LBM"
7864 SnapshotFormat=6;
7865 break;
7866 }
7867 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7868
7869 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7870 return D_O_K;
7871 }
7872
7873
7874 43 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7875 {
7876 PALETTE tmp;
7877
7878
2/2
✓ Branch 0 taken 11008 times.
✓ Branch 1 taken 43 times.
11051 for(int32_t i=0; i<256; i++)
7879 {
7880 11008 tmp[i].r=r;
7881 11008 tmp[i].g=g;
7882 11008 tmp[i].b=b;
7883 11008 }
7884
7885 43 fade_interpolate(src,tmp,dest,pos,from,to);
7886 43 }
7887
7888 43 void system_pal()
7889 {
7890 43 is_sys_pal = true;
7891 static PALETTE pal;
7892 43 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
7893
7894 // set up the grayscale palette
7895
2/2
✓ Branch 0 taken 2752 times.
✓ Branch 1 taken 43 times.
2795 for(int32_t i=128; i<192; i++)
7896 {
7897 2752 pal[i].r = i-128;
7898 2752 pal[i].g = i-128;
7899 2752 pal[i].b = i-128;
7900 2752 }
7901 43 load_colorset(gui_colorset, pal, jwin_a5_colors);
7902
7903 43 color_layer(pal, pal, 24,16,16, 28, 128,191);
7904
7905
2/2
✓ Branch 0 taken 5504 times.
✓ Branch 1 taken 43 times.
5547 for(int32_t i=0; i<256; i+=2)
7906 {
7907 5504 int32_t v = (i>>3)+2;
7908 5504 int32_t c = (i>>3)+192;
7909 5504 pal[c] = _RGB(v,v,v+(v>>1));
7910 /*
7911 if(i<240)
7912 {
7913 _allegro_hline(tmp_scr,0,i,319,c);
7914 _allegro_hline(tmp_scr,0,i+1,319,c);
7915 }
7916 */
7917 5504 }
7918
7919 // draw the vertical screen gradient
7920
2/2
✓ Branch 0 taken 10320 times.
✓ Branch 1 taken 43 times.
10363 for(int32_t i=0; i<240; ++i)
7921 {
7922 10320 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
7923 10320 }
7924
7925 /*
7926 palrstart= 10*63/255; palrend=166*63/255;
7927 palgstart= 36*63/255; palgend=202*63/255;
7928 palbstart=106*63/255; palbend=240*63/255;
7929 paldivs=32;
7930 for(int32_t i=0; i<paldivs; i++)
7931 {
7932 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
7933 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
7934 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
7935 }
7936 */
7937 43 BITMAP *panorama = create_bitmap_ex(8,256,224);
7938 int32_t ts_height, ts_start;
7939
7940
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
7941 {
7942 clear_to_color(panorama,0);
7943 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
7944 ts_height=224-passive_subscreen_height;
7945 ts_start=28;
7946 }
7947 else
7948 {
7949 43 blit(framebuf,panorama,0,0,0,0,256,224);
7950 43 ts_height=224;
7951 43 ts_start=0;
7952 }
7953
7954 // gray scale the current frame
7955
2/2
✓ Branch 0 taken 9632 times.
✓ Branch 1 taken 43 times.
9675 for(int32_t y=0; y<ts_height; y++)
7956 {
7957
2/2
✓ Branch 0 taken 2465792 times.
✓ Branch 1 taken 9632 times.
2475424 for(int32_t x=0; x<256; x++)
7958 {
7959 2465792 int32_t c = panorama->line[y+ts_start][x];
7960
2/2
✓ Branch 0 taken 2459902 times.
✓ Branch 1 taken 5890 times.
2465792 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
7961 2465792 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
7962 2465792 }
7963 9632 }
7964
7965 43 destroy_bitmap(panorama);
7966
7967 // display everything
7968 43 vsync();
7969 43 hw_palette = &pal;
7970 43 update_hw_pal = true;
7971
7972 // sys_pal = pal;
7973 43 memcpy(sys_pal,pal,sizeof(pal));
7974 43 }
7975
7976 void system_pal2()
7977 {
7978 is_sys_pal = true;
7979 static PALETTE RAMpal2;
7980 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
7981
7982 /* Windows 2000 colors
7983 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
7984 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
7985 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
7986 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
7987 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
7988 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
7989 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
7990 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
7991
7992 byte palrstart= 10*63/255, palrend=166*63/255,
7993 palgstart= 36*63/255, palgend=202*63/255,
7994 palbstart=106*63/255, palbend=240*63/255,
7995 paldivs=7;
7996 for(int32_t i=0; i<paldivs; i++)
7997 {
7998 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
7999 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8000 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8001 }
8002 */
8003
8004 /* Windows 98 colors
8005 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8006 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8007 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8008 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8009 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8010 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8011 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8012 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8013
8014 byte palrstart= 0*63/255, palrend=166*63/255,
8015 palgstart= 0*63/255, palgend=202*63/255,
8016 palbstart=128*63/255, palbend=240*63/255,
8017 paldivs=7;
8018 for(int32_t i=0; i<paldivs; i++)
8019 {
8020 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8021 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8022 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8023 }
8024 */
8025
8026 /* Windows 99 colors
8027 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8028 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8029 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8030 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8031 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8032 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8033 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8034 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8035 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8036
8037 byte palrstart= 0*63/255, palrend=166*63/255,
8038 palgstart= 0*63/255, palgend=202*63/255,
8039
8040 palbstart=128*63/255, palbend=240*63/255,
8041 paldivs=6;
8042 for(int32_t i=0; i<paldivs; i++)
8043 {
8044 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8045 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8046 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8047 }
8048 */
8049
8050
8051
8052 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8053 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8054 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8055 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8056 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8057 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8058 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8059 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8060 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8061
8062 byte palrstart= 0*63/255, palrend=166*63/255,
8063 palgstart= 0*63/255, palgend=202*63/255,
8064 palbstart=128*63/255, palbend=240*63/255,
8065 paldivs=6;
8066
8067 for(int32_t i=0; i<paldivs; i++)
8068 {
8069 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8070 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8071 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8072 }
8073
8074 gui_bg_color=jwin_pal[jcBOX];
8075 gui_fg_color=jwin_pal[jcBOXFG];
8076
8077 jwin_set_colors(jwin_pal);
8078
8079
8080 // set up the new palette
8081 for(int32_t i=128; i<192; i++)
8082 {
8083 RAMpal2[i].r = i-128;
8084 RAMpal2[i].g = i-128;
8085 RAMpal2[i].b = i-128;
8086 }
8087
8088 /*
8089 for(int32_t i=0; i<64; i++)
8090 {
8091 RAMpal2[128+i] = _RGB(i,i,i)1));
8092 }
8093 */
8094
8095 /*
8096
8097 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8098 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8099 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8100 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8101 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8102 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8103 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8104
8105 gui_fg_color=vc(14);
8106 gui_bg_color=vc(1);
8107
8108 jwin_set_colors(jwin_pal);
8109 */
8110
8111 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8112
8113 // set up the colors for the vertical screen gradient
8114 for(int32_t i=0; i<256; i+=2)
8115 {
8116 int32_t v = (i>>3)+2;
8117 int32_t c = (i>>3)+192;
8118 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8119
8120 /*
8121 if(i<240)
8122 {
8123 _allegro_hline(tmp_scr,0,i,319,c);
8124 _allegro_hline(tmp_scr,0,i+1,319,c);
8125 }
8126 */
8127 }
8128
8129 // hw_palette = &RAMpal;
8130 // update_hw_pal = true;
8131
8132 for(int32_t i=0; i<240; ++i)
8133 {
8134 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8135 }
8136
8137 /*
8138 byte palrstart= 10*63/255, palrend=166*63/255,
8139 palgstart= 36*63/255, palgend=202*63/255,
8140 palbstart=106*63/255, palbend=240*63/255,
8141 paldivs=32;
8142 for(int32_t i=0; i<paldivs; i++)
8143 {
8144 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8145 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8146 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8147 }
8148 */
8149 BITMAP *panorama = create_bitmap_ex(8,256,224);
8150 int32_t ts_height, ts_start;
8151
8152 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8153 {
8154 clear_to_color(panorama,0);
8155 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8156 ts_height=224-passive_subscreen_height;
8157 ts_start=28;
8158 }
8159 else
8160 {
8161 blit(framebuf,panorama,0,0,0,0,256,224);
8162 ts_height=224;
8163 ts_start=0;
8164 }
8165
8166 // gray scale the current frame
8167 for(int32_t y=0; y<ts_height; y++)
8168 {
8169 for(int32_t x=0; x<256; x++)
8170 {
8171 int32_t c = panorama->line[y+ts_start][x];
8172 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8173 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8174 }
8175 }
8176
8177 destroy_bitmap(panorama);
8178
8179 // display everything
8180 vsync();
8181 hw_palette = &RAMpal2;
8182 update_hw_pal = true;
8183
8184 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8185
8186 // sys_pal = pal;
8187 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8188 }
8189
8190 static uint32_t entered_sys_pal = 0;
8191 14 void enter_sys_pal()
8192 {
8193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8194 {
8195 if(entered_sys_pal)
8196 ++entered_sys_pal;
8197 return;
8198 }
8199 14 system_pal();
8200 14 ++entered_sys_pal;
8201 14 }
8202 14 void exit_sys_pal()
8203 {
8204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8205 {
8206
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8207 {
8208 14 game_pal();
8209 14 }
8210 14 }
8211 14 }
8212
8213 void switch_out_callback()
8214 {
8215 if (pause_in_background)
8216 {
8217 callback_switchin = 3;
8218 return;
8219 }
8220
8221 #ifdef _WIN32
8222 if(midi_patch_fix==0 || currmidi==-1)
8223 return;
8224
8225
8226 paused_midi_pos = midi_pos;
8227 zc_stop_midi();
8228 midi_paused=true;
8229 midi_suspended = midissuspHALTED;
8230 #endif
8231 }
8232
8233 void switch_in_callback()
8234 {
8235 if(pause_in_background)
8236 {
8237 return;
8238 }
8239
8240 #ifdef _WIN32
8241 if(midi_patch_fix==0 || currmidi==-1)
8242 return;
8243
8244 else
8245 {
8246 callback_switchin = 1;
8247 midi_suspended = midissuspRESUME;
8248 }
8249 #endif
8250 }
8251
8252 257 void game_pal()
8253 {
8254 257 is_sys_pal = false;
8255 257 entered_sys_pal = 0;
8256 257 clear_to_color(screen,BLACK);
8257 257 hw_palette = &RAMpal;
8258 257 update_hw_pal = true;
8259 257 }
8260
8261 static char bar_str[] = "";
8262
8263 14 void music_pause()
8264 {
8265 //al_pause_duh(tmplayer);
8266 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8267 14 zc_midi_pause();
8268 14 midi_paused=true;
8269 14 }
8270
8271 void music_resume()
8272 {
8273 //al_resume_duh(tmplayer);
8274 zcmusic_pause(zcmusic, ZCM_RESUME);
8275 zc_midi_resume();
8276 midi_paused=false;
8277 }
8278
8279 5320 void music_stop()
8280 {
8281 //al_stop_duh(tmplayer);
8282 //unload_duh(tmusic);
8283 //tmusic=NULL;
8284 //tmplayer=NULL;
8285 5320 zcmusic_stop(zcmusic);
8286 5320 zcmusic_unload_file(zcmusic);
8287 5320 zc_stop_midi();
8288 5320 midi_paused=false;
8289 5320 currmidi=-1;
8290 5320 }
8291
8292 void System()
8293 {
8294 mouse_down=gui_mouse_b();
8295 music_pause();
8296 pause_all_sfx();
8297 MenuOpen = true;
8298 system_pal();
8299 // FONT *oldfont=font;
8300 // font=tfont;
8301
8302 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8303 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8304
8305 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8306 #if DEVLEVEL > 1
8307 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8308 #endif
8309 game_menu[3].flags =
8310 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8311 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8312 clear_keybuf();
8313
8314 DIALOG_PLAYER *p;
8315
8316 clear_bitmap(menu_bmp);
8317 oldscreen = screen;
8318 screen = menu_bmp;
8319
8320 p = init_dialog(system_dlg,-1);
8321
8322 // drop the menu on startup if menu button pressed
8323 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8324 simulate_keypress(KEY_G << 8);
8325
8326 do
8327 {
8328 if(close_button_quit)
8329 {
8330 close_button_quit = false;
8331 f_Quit(qEXIT);
8332 if(Quit) break;
8333 }
8334 rest(17);
8335
8336 if(mouse_down && !gui_mouse_b())
8337 mouse_down=0;
8338
8339 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8340 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8341 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8342
8343 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8344 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8345 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8346 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
8347 settings_menu[9].flags = TransLayers?D_SELECTED:0;
8348 settings_menu[10].flags = NESquit?D_SELECTED:0;
8349 settings_menu[11].flags = volkeys?D_SELECTED:0;
8350
8351 window_menu[0].flags = DragAspect?D_SELECTED:0;
8352 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
8353 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
8354 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
8355
8356 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8357 options_menu[5].flags = (midi_patch_fix)?D_SELECTED:0;
8358
8359 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8360 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8361 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8362
8363 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8364 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8365 misc_menu[14].flags =(clearConsoleOnReload)?D_SELECTED:0;
8366 misc_menu[15].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8367
8368 bool nocheat = (replay_is_replaying() || !Playing
8369 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
8370 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
8371 cheat_menu[0].flags = 0;
8372 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8373 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8374 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8375 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8376 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8377 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8378 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8379 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8380 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8381
8382 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8383 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8384 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8385 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8386 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8387 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8388 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8389 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8390 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8391 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8392 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8393 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8394 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8395 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8396 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8397
8398 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
8399 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8400
8401 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8402 (char *)"Disable recording new saves" :
8403 (char *)"Enable recording new saves";
8404 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8405 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8406 (char *)"Stop recording" :
8407 (char *)"Stop replaying";
8408 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8409 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8410 (char *)"Disable snapshot all frames" :
8411 (char *)"Enable snapshot all frames";
8412
8413 reset_snapshot_format_menu();
8414 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8415
8416 if(debug_enabled)
8417 {
8418 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8419 }
8420
8421 if(gui_mouse_b() && !mouse_down)
8422 break;
8423
8424 // press menu to drop the menu
8425 if(rMbtn())
8426 simulate_keypress(KEY_G << 8);
8427
8428 if(input_idle(true) > after_time())
8429 // run Screeen Saver
8430 {
8431 // Screen saver enabled for now.
8432 clear_keybuf();
8433 Matrix(ss_speed, ss_density, 0);
8434 system_pal();
8435 broadcast_dialog_message(MSG_DRAW, 0);
8436 }
8437
8438 update_hw_screen();
8439 }
8440 while(update_dialog(p));
8441
8442 screen = oldscreen;
8443
8444 // font=oldfont;
8445 mouse_down=gui_mouse_b();
8446 shutdown_dialog(p);
8447 MenuOpen = false;
8448 if(Quit)
8449 {
8450 kill_sfx();
8451 music_stop();
8452 update_hw_screen();
8453 }
8454 else
8455 {
8456 game_pal();
8457 music_resume();
8458 resume_all_sfx();
8459
8460 if(rc)
8461 ringcolor(false);
8462 }
8463
8464 eat_buttons();
8465
8466 rc=false;
8467 clear_keybuf();
8468 // text_mode(0);
8469 }
8470
8471 29 void fix_dialogs()
8472 {
8473 29 jwin_center_dialog(about_dlg);
8474 29 jwin_center_dialog(gamepad_dlg);
8475 29 jwin_center_dialog(credits_dlg);
8476 29 jwin_center_dialog(gamemode_dlg);
8477 29 jwin_center_dialog(getnum_dlg);
8478 29 jwin_center_dialog(goto_dlg);
8479 29 jwin_center_dialog(keyboard_control_dlg);
8480 29 jwin_center_dialog(midi_dlg);
8481 29 jwin_center_dialog(quest_dlg);
8482 29 jwin_center_dialog(scrsaver_dlg);
8483 29 jwin_center_dialog(sound_dlg);
8484 29 jwin_center_dialog(triforce_dlg);
8485
8486 // digi_dp[1] += scrx;
8487 // digi_dp[2] += scry;
8488 // midi_dp[1] += scrx;
8489 // midi_dp[2] += scry;
8490 // pan_dp[1] += scrx;
8491 // pan_dp[2] += scry;
8492 // emus_dp[1] += scrx;
8493 // emus_dp[2] += scry;
8494 // buf_dp[1] += scrx;
8495 // buf_dp[2] += scry;
8496 // sfx_dp[1] += scrx;
8497 // sfx_dp[2] += scry;
8498 29 }
8499
8500 /*****************************/
8501 /**** Custom Sound System ****/
8502 /*****************************/
8503
8504 2295 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8505 {
8506
3/4
✓ Branch 0 taken 2061 times.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 2295 times.
✗ Branch 3 not taken.
2295 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8507 }
8508
8509 // Run an NSF, or a MIDI if the NSF is missing somehow.
8510 83 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8511 {
8512 83 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8513
8514 // Found it
8515
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 35 times.
83 if(newzcmusic!=NULL)
8516 {
8517 48 zcmusic_stop(zcmusic);
8518 48 zcmusic_unload_file(zcmusic);
8519 48 zc_stop_midi();
8520
8521 48 zcmusic=newzcmusic;
8522 48 zcmusic_play(zcmusic, emusic_volume);
8523
8524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(track>0)
8525 48 zcmusic_change_track(zcmusic,track);
8526
8527 48 return true;
8528 }
8529
8530 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8531
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 else if(midi>-1000)
8532 jukebox(midi);
8533
8534 35 return false;
8535 83 }
8536
8537 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8538 {
8539 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8540 // Found it
8541 if(newzcmusic!=NULL)
8542 {
8543 zcmusic_stop(zcmusic);
8544 zcmusic_unload_file(zcmusic);
8545 zc_stop_midi();
8546
8547 zcmusic=newzcmusic;
8548 zcmusic_play(zcmusic, emusic_volume);
8549
8550 if(track>0)
8551 zcmusic_change_track(zcmusic,track);
8552
8553 return true;
8554 }
8555
8556 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8557 else if(midi>-1000)
8558 jukebox(midi);
8559
8560 return false;
8561 }
8562
8563 int32_t get_zcmusicpos()
8564 {
8565 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8566 return debugtracething;
8567 return 0;
8568 }
8569
8570 void set_zcmusicpos(int32_t position)
8571 {
8572 zcmusic_set_curpos(zcmusic, position);
8573 }
8574
8575 void set_zcmusicspeed(int32_t speed)
8576 {
8577 int32_t newspeed = vbound(speed, 0, 10000);
8578 zcmusic_set_speed(zcmusic, newspeed);
8579 }
8580
8581 1133 void jukebox(int32_t index,int32_t loop)
8582 {
8583 1133 music_stop();
8584
8585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if(index<0) index=MAXMIDIS-1;
8586
8587
1/2
✓ Branch 0 taken 1133 times.
✗ Branch 1 not taken.
1133 if(index>=MAXMIDIS) index=0;
8588
8589 1133 music_stop();
8590
8591 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8592 // stuck notes when a song stops. This fixes it.
8593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if(strcmp(midi_driver->name, "DIGMID")==0)
8594 zc_set_volume(0, 0);
8595
8596 1133 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8597 1133 zc_play_midi((MIDI*)tunes[index].data,loop);
8598
8599
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 377 times.
1133 if(tunes[index].start>0)
8600 377 zc_midi_seek(tunes[index].start);
8601
8602 1133 midi_loop_start = tunes[index].loop_start;
8603 1133 midi_loop_end = tunes[index].loop_end;
8604
8605 1133 currmidi=index;
8606 1133 master_volume(digi_volume,midi_volume);
8607 1133 midi_paused=false;
8608 1133 }
8609
8610 8589 void jukebox(int32_t index)
8611 {
8612
1/2
✓ Branch 0 taken 8589 times.
✗ Branch 1 not taken.
8589 if(index<0) index=MAXMIDIS-1;
8613
8614
1/2
✓ Branch 0 taken 8589 times.
✗ Branch 1 not taken.
8589 if(index>=MAXMIDIS) index=0;
8615
8616 // do nothing if it's already playing
8617
3/4
✓ Branch 0 taken 7456 times.
✓ Branch 1 taken 1133 times.
✓ Branch 2 taken 7456 times.
✗ Branch 3 not taken.
8589 if(index==currmidi && midi_pos>=0)
8618 {
8619 7456 midi_paused=false;
8620 7456 return;
8621 }
8622
8623 1133 jukebox(index,tunes[index].loop);
8624 8589 }
8625
8626 9829 void play_DmapMusic()
8627 {
8628 static char tfile[2048];
8629 static int32_t ttrack=0;
8630 9829 bool domidi=false;
8631
8632
2/2
✓ Branch 0 taken 1330 times.
✓ Branch 1 taken 8499 times.
9829 if(DMaps[currdmap].tmusic[0]!=0)
8633 {
8634
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 945 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1715 if(zcmusic==NULL ||
8635
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8636
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8637 {
8638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945 times.
945 if(zcmusic != NULL)
8639 {
8640 zcmusic_stop(zcmusic);
8641 zcmusic_unload_file(zcmusic);
8642 zcmusic = NULL;
8643 }
8644
8645 945 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8646
8647
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 859 times.
945 if(zcmusic!=NULL)
8648 {
8649 86 zc_stop_midi();
8650 86 strcpy(tfile,DMaps[currdmap].tmusic);
8651 86 zcmusic_play(zcmusic, emusic_volume);
8652 86 int32_t temptracks=0;
8653 86 temptracks=zcmusic_get_tracks(zcmusic);
8654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8655 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8656 86 zcmusic_change_track(zcmusic,ttrack);
8657 86 }
8658 else
8659 {
8660 859 tfile[0] = 0;
8661 859 domidi=true;
8662 }
8663 945 }
8664 1330 }
8665 else
8666 {
8667 8499 domidi=true;
8668 }
8669
8670
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 9358 times.
9829 if(domidi)
8671 {
8672 9358 int32_t m=DMaps[currdmap].midi;
8673
8674
3/4
✓ Branch 0 taken 9243 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
9358 switch(m)
8675 {
8676 case 1:
8677 105 jukebox(ZC_MIDI_OVERWORLD);
8678 105 break;
8679
8680 case 2:
8681 10 jukebox(ZC_MIDI_DUNGEON);
8682 10 break;
8683
8684 case 3:
8685 jukebox(ZC_MIDI_LEVEL9);
8686 break;
8687
8688 default:
8689
3/4
✓ Branch 0 taken 8329 times.
✓ Branch 1 taken 914 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8329 times.
9243 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8690 8329 jukebox(m+MIDIOFFSET_DMAP);
8691 else
8692 914 music_stop();
8693 9243 }
8694 9358 }
8695 9829 }
8696
8697 9866 void playLevelMusic()
8698 {
8699 9866 int32_t m=tmpscr->screen_midi;
8700
8701
3/6
✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
9866 switch(m)
8702 {
8703 case -2:
8704 12 music_stop();
8705 12 break;
8706
8707 case -1:
8708 9813 play_DmapMusic();
8709 9813 break;
8710
8711 case 1:
8712 jukebox(ZC_MIDI_OVERWORLD);
8713 break;
8714
8715 case 2:
8716 jukebox(ZC_MIDI_DUNGEON);
8717 break;
8718
8719 case 3:
8720 jukebox(ZC_MIDI_LEVEL9);
8721 break;
8722
8723 default:
8724
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8725 41 jukebox(m+MIDIOFFSET_MAPSCR);
8726 else
8727 music_stop();
8728 41 }
8729 9866 }
8730
8731 1162 void master_volume(int32_t dv,int32_t mv)
8732 {
8733
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1162 times.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1162 times.
✗ Branch 7 not taken.
1162 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8734
8735
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1162 times.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1162 times.
✗ Branch 7 not taken.
1162 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8736
8737
6/6
✓ Branch 0 taken 1132 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 1160 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1130 times.
✓ Branch 5 taken 30 times.
1162 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8738 1162 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8739 1162 }
8740
8741 /*****************/
8742 /***** SFX *****/
8743 /*****************/
8744
8745 // array of voices, one for each sfx sample in the data file
8746 // 0+ = voice #
8747 // -1 = voice not allocated
8748 29 void Z_init_sound()
8749 {
8750
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i=0; i<WAV_COUNT; i++)
8751 7424 sfx_voice[i]=-1;
8752
8753
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 29 times.
232 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8754 203 tunes[i].data = (MIDI*)mididata[i].dat;
8755
8756
2/2
✓ Branch 0 taken 7308 times.
✓ Branch 1 taken 29 times.
7337 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8757 7308 tunes[ZC_MIDI_COUNT+j].data=NULL;
8758
8759 29 master_volume(digi_volume,midi_volume);
8760 29 }
8761
8762 // returns number of voices currently allocated
8763 int32_t sfx_count()
8764 {
8765 int32_t c=0;
8766
8767 for(int32_t i=0; i<WAV_COUNT; i++)
8768 if(sfx_voice[i]!=-1)
8769 ++c;
8770
8771 return c;
8772 }
8773
8774 // clean up finished samples
8775 6480723 void sfx_cleanup()
8776 {
8777
2/2
✓ Branch 0 taken 1659065088 times.
✓ Branch 1 taken 6480723 times.
1665545811 for(int32_t i=0; i<WAV_COUNT; i++)
8778
3/4
✓ Branch 0 taken 560755 times.
✓ Branch 1 taken 1658504333 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 560755 times.
1659625843 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8779 {
8780 560755 deallocate_voice(sfx_voice[i]);
8781 560755 sfx_voice[i]=-1;
8782 560755 }
8783 6480723 }
8784
8785 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8786 // if a voice is already allocated (and/or playing), then it just returns true
8787 // Returns true: voice is allocated
8788 // false: unsuccessful
8789 838762 bool sfx_init(int32_t index)
8790 {
8791 // check index
8792
3/4
✓ Branch 0 taken 620761 times.
✓ Branch 1 taken 218001 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 620761 times.
838762 if(index<=0 || index>=WAV_COUNT)
8793 218001 return false;
8794
8795
2/2
✓ Branch 0 taken 59980 times.
✓ Branch 1 taken 560781 times.
620761 if(sfx_voice[index]==-1)
8796 {
8797
2/2
✓ Branch 0 taken 110294 times.
✓ Branch 1 taken 450487 times.
560781 if(sfxdat)
8798 {
8799
1/2
✓ Branch 0 taken 110294 times.
✗ Branch 1 not taken.
110294 if(index<Z35)
8800 {
8801 110294 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8802 110294 }
8803 else
8804 {
8805 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8806 }
8807 110294 }
8808 else
8809 {
8810 450487 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8811 }
8812
8813 560781 voice_set_volume(sfx_voice[index], sfx_volume);
8814 560781 }
8815
8816 620761 return sfx_voice[index] != -1;
8817 838762 }
8818
8819 // plays an sfx sample
8820 732250 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8821 {
8822
2/2
✓ Branch 0 taken 550996 times.
✓ Branch 1 taken 181254 times.
732250 if(!sfx_init(index))
8823 181254 return;
8824
8825 550996 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8826 550996 voice_set_pan(sfx_voice[index],pan);
8827
8828 550996 int32_t pos = voice_get_position(sfx_voice[index]);
8829
8830
2/2
✓ Branch 0 taken 259936 times.
✓ Branch 1 taken 291060 times.
550996 if(restart) voice_set_position(sfx_voice[index],0);
8831
8832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550996 times.
550996 if(pos<=0)
8833 550996 voice_start(sfx_voice[index]);
8834
8835
3/4
✓ Branch 0 taken 291060 times.
✓ Branch 1 taken 259936 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 291060 times.
550996 if (restart && replay_is_debug())
8836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291060 times.
291060 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8837 732250 }
8838
8839 // true if sfx is allocated
8840 32243 bool sfx_allocated(int32_t index)
8841 {
8842
3/4
✓ Branch 0 taken 9403 times.
✓ Branch 1 taken 22840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9403 times.
32243 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8843 }
8844
8845 // start it (in loop mode) if it's not already playing,
8846 // otherwise adjust it to play in loop mode -DD
8847 106512 void cont_sfx(int32_t index)
8848 {
8849
2/2
✓ Branch 0 taken 36747 times.
✓ Branch 1 taken 69765 times.
106512 if(!sfx_init(index))
8850 {
8851 36747 return;
8852 }
8853
8854
1/2
✓ Branch 0 taken 69765 times.
✗ Branch 1 not taken.
69765 if(voice_get_position(sfx_voice[index])<=0)
8855 {
8856 69765 voice_set_position(sfx_voice[index],0);
8857 69765 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8858 69765 voice_start(sfx_voice[index]);
8859 69765 }
8860 else
8861 {
8862 adjust_sfx(index, 128, true);
8863 }
8864 106512 }
8865
8866 // adjust parameters while playing
8867 3547 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8868 {
8869
5/6
✓ Branch 0 taken 2124 times.
✓ Branch 1 taken 1423 times.
✓ Branch 2 taken 2124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2110 times.
3547 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8870 3533 return;
8871
8872 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8873 14 voice_set_pan(sfx_voice[index],pan);
8874 3547 }
8875
8876 // pauses a voice
8877 1468 void pause_sfx(int32_t index)
8878 {
8879
3/6
✓ Branch 0 taken 1468 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1468 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1468 times.
1468 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8880 voice_stop(sfx_voice[index]);
8881 1468 }
8882
8883 // resumes a voice
8884 637 void resume_sfx(int32_t index)
8885 {
8886
3/6
✓ Branch 0 taken 637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 637 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 637 times.
637 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8887 voice_start(sfx_voice[index]);
8888 637 }
8889
8890 // pauses all active voices
8891 244 void pause_all_sfx()
8892 {
8893
2/2
✓ Branch 0 taken 62464 times.
✓ Branch 1 taken 244 times.
62708 for(int32_t i=0; i<WAV_COUNT; i++)
8894
2/2
✓ Branch 0 taken 62462 times.
✓ Branch 1 taken 2 times.
62466 if(sfx_voice[i]!=-1)
8895 2 voice_stop(sfx_voice[i]);
8896 244 }
8897
8898 // resumes all paused voices
8899 230 void resume_all_sfx()
8900 {
8901
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 230 times.
59110 for(int32_t i=0; i<WAV_COUNT; i++)
8902
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(sfx_voice[i]!=-1)
8903 voice_start(sfx_voice[i]);
8904 230 }
8905
8906 // stops an sfx and deallocates the voice
8907 5203476 void stop_sfx(int32_t index)
8908 {
8909
3/4
✓ Branch 0 taken 5102116 times.
✓ Branch 1 taken 101360 times.
✓ Branch 2 taken 5102116 times.
✗ Branch 3 not taken.
5203476 if(index<=0 || index>=WAV_COUNT)
8910 101360 return;
8911
8912
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5102103 times.
5102116 if(sfx_voice[index]!=-1)
8913 {
8914 13 deallocate_voice(sfx_voice[index]);
8915 13 sfx_voice[index]=-1;
8916 13 }
8917 5203476 }
8918
8919 // Stops SFX played by Hero's item of the given family
8920 131169 void stop_item_sfx(int32_t family)
8921 {
8922 131169 int32_t id=current_item_id(family);
8923
8924
2/2
✓ Branch 0 taken 130841 times.
✓ Branch 1 taken 328 times.
131169 if(id<0)
8925 130841 return;
8926
8927 328 stop_sfx(itemsbuf[id].usesound);
8928 131169 }
8929
8930 1802 void kill_sfx()
8931 {
8932
2/2
✓ Branch 0 taken 461312 times.
✓ Branch 1 taken 1802 times.
463114 for(int32_t i=0; i<WAV_COUNT; i++)
8933
2/2
✓ Branch 0 taken 461299 times.
✓ Branch 1 taken 13 times.
461325 if(sfx_voice[i]!=-1)
8934 {
8935 13 deallocate_voice(sfx_voice[i]);
8936 13 sfx_voice[i]=-1;
8937 13 }
8938 1802 }
8939
8940 504198 int32_t pan(int32_t x)
8941 {
8942
1/4
✓ Branch 0 taken 504198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
504198 switch(pan_style)
8943 {
8944 case 0:
8945 return 128;
8946
8947 case 1:
8948 504198 return vbound((x>>1)+68,0,255);
8949
8950 case 2:
8951 return vbound(((x*3)>>2)+36,0,255);
8952 }
8953
8954 return vbound(x,0,255);
8955 504198 }
8956
8957 /*******************************/
8958 /******* Input Handlers ********/
8959 /*******************************/
8960
8961 16584516 bool joybtn(int32_t b)
8962 {
8963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16584516 times.
16584516 if(b == 0)
8964 return false;
8965
8966 16584516 return joy[joystick_index].button[b-1].b !=0;
8967 16584516 }
8968
8969 const char* joybtn_name(int32_t b)
8970 {
8971 if(b == 0)
8972 return "";
8973
8974 return joy[joystick_index].button[b-1].name;
8975 }
8976
8977 int32_t next_press_key();
8978
8979 int32_t next_press_btn()
8980 {
8981 clear_keybuf();
8982 /*bool b[joy[joystick_index].num_buttons+1];
8983
8984 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8985 b[i]=joybtn(i);*/
8986
8987 //first, we need to wait until they're pressing no buttons
8988 for(;;)
8989 {
8990 if(keypressed())
8991 {
8992 switch(readkey()>>8)
8993 {
8994 case KEY_ESC:
8995 return -1;
8996
8997 case KEY_SPACE:
8998 return 0;
8999 }
9000 }
9001
9002 poll_joystick();
9003 bool done = true;
9004
9005 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9006 {
9007 if(joybtn(i)) done = false;
9008 }
9009
9010 if(done) break;
9011 rest(1);
9012 }
9013
9014 //now, we need to wait for them to press any button
9015 for(;;)
9016 {
9017 if(keypressed())
9018 {
9019 switch(readkey()>>8)
9020 {
9021 case KEY_ESC:
9022 return -1;
9023
9024 case KEY_SPACE:
9025 return 0;
9026 }
9027 }
9028
9029 poll_joystick();
9030
9031 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9032 {
9033 if(joybtn(i)) return i;
9034 }
9035 rest(1);
9036 }
9037 }
9038
9039 134574253 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9040 {
9041
2/2
✓ Branch 0 taken 129784481 times.
✓ Branch 1 taken 4789772 times.
134574253 bool ret = btn && !flag;
9042
2/2
✓ Branch 0 taken 117573131 times.
✓ Branch 1 taken 17001122 times.
134574253 flag = rawbtn ? *rawbtn : btn;
9043
9044 134574253 return ret;
9045 }
9046 1337132 static bool rButtonPeek(bool btn, bool flag)
9047 {
9048
2/2
✓ Branch 0 taken 1249424 times.
✓ Branch 1 taken 87708 times.
1337132 if(!btn)
9049 {
9050 1249424 return false;
9051 }
9052
2/2
✓ Branch 0 taken 14956 times.
✓ Branch 1 taken 72752 times.
87708 else if(!flag)
9053 {
9054 14956 return true;
9055 }
9056
9057 72752 return false;
9058 1337132 }
9059
9060 // Updated only by keyboard/gamepad.
9061 // If in replay mode, this is set directly by the replay system.
9062 // This should never be read from directly - use control_state instead.
9063 bool raw_control_state[ZC_CONTROL_STATES];
9064
9065 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9066 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9067 // lasts until the next call to load_control_state.
9068 bool control_state[ZC_CONTROL_STATES];
9069 bool disable_control[ZC_CONTROL_STATES];
9070 bool drunk_toggle_state[11];
9071 bool disabledKeys[127];
9072 bool KeyInput[127];
9073 bool KeyPress[127];
9074
9075 bool key_current_frame[127];
9076 bool key_previous_frame[127];
9077
9078 static bool key_system[127];
9079 static bool key_system_previous[127];
9080 static bool key_system_press[127];
9081
9082 bool button_press[ZC_CONTROL_STATES];
9083 bool button_hold[ZC_CONTROL_STATES];
9084
9085 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9086 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9087 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9088 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9089 #define STICK_PRECISION 56 //define your own sensitivity
9090
9091 5438197 void load_control_state()
9092 {
9093 5438197 load_control_called_this_frame = true;
9094
9095
3/4
✓ Branch 0 taken 2566996 times.
✓ Branch 1 taken 2871201 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2566996 times.
5438197 if (replay_get_version() >= 8 && replay_get_version() < 11)
9096 {
9097
2/2
✓ Branch 0 taken 46205928 times.
✓ Branch 1 taken 2566996 times.
48772924 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9098 46205928 down_control_states[i] = raw_control_state[i];
9099 2566996 }
9100
9101
1/2
✓ Branch 0 taken 5438197 times.
✗ Branch 1 not taken.
5438197 if (!replay_is_replaying())
9102 {
9103 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9104 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9105 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9106 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9107 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9108 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9109 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9110 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9111 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9112 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9113 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9114 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9115 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9116 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9117
9118 if(num_joysticks != 0)
9119 {
9120 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9121 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9122 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9123 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9124 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9125 }
9126 else
9127 {
9128 raw_control_state[14] = false;
9129 raw_control_state[15] = false;
9130 raw_control_state[16] = false;
9131 raw_control_state[17] = false;
9132 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9133 }
9134 }
9135
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5438194 times.
5438197 if (replay_is_active())
9136 {
9137
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 4422979 times.
5438194 if (replay_get_version() < 3)
9138 1015215 replay_poll();
9139
3/4
✓ Branch 0 taken 4422979 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2661604 times.
✓ Branch 3 taken 1761375 times.
4422979 else if (replay_is_replaying() && replay_get_version() < 6)
9140 1761375 replay_peek_input();
9141
4/6
✓ Branch 0 taken 2661604 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2566996 times.
✓ Branch 3 taken 94608 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2566996 times.
2661604 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9142 2566996 replay_peek_input();
9143
2/2
✓ Branch 0 taken 4320728 times.
✓ Branch 1 taken 1117466 times.
5438194 if (replay_get_version() == 8)
9144 1117466 update_keys();
9145 5438194 }
9146
9147 // Some test replay files were made before a serious input bug was fixed, so instead
9148 // of re-doing them or tossing them out, just check for that zplay version.
9149
3/4
✓ Branch 0 taken 5438191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 5316291 times.
5438197 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9150
2/2
✓ Branch 0 taken 97887438 times.
✓ Branch 1 taken 5438191 times.
103325629 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9151 {
9152 97887438 control_state[i] = raw_control_state[i];
9153
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 48400128 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
97887438 if (botched_input && !control_state[i])
9154 47077142 down_control_states[i] = false;
9155 97887438 }
9156
9157 5438191 button_press[0]=rButton(control_state[0],button_hold[0]);
9158 5438191 button_press[1]=rButton(control_state[1],button_hold[1]);
9159 5438191 button_press[2]=rButton(control_state[2],button_hold[2]);
9160 5438191 button_press[3]=rButton(control_state[3],button_hold[3]);
9161 5438191 button_press[4]=rButton(control_state[4],button_hold[4]);
9162 5438191 button_press[5]=rButton(control_state[5],button_hold[5]);
9163 5438191 button_press[6]=rButton(control_state[6],button_hold[6]);
9164 5438191 button_press[7]=rButton(control_state[7],button_hold[7]);
9165 5438191 button_press[8]=rButton(control_state[8],button_hold[8]);
9166 5438191 button_press[9]=rButton(control_state[9],button_hold[9]);
9167 5438191 button_press[10]=rButton(control_state[10],button_hold[10]);
9168 5438191 button_press[11]=rButton(control_state[11],button_hold[11]);
9169 5438191 button_press[12]=rButton(control_state[12],button_hold[12]);
9170 5438191 button_press[13]=rButton(control_state[13],button_hold[13]);
9171 5438191 button_press[14]=rButton(control_state[14],button_hold[14]);
9172 5438191 button_press[15]=rButton(control_state[15],button_hold[15]);
9173 5438191 button_press[16]=rButton(control_state[16],button_hold[16]);
9174 5438191 button_press[17]=rButton(control_state[17],button_hold[17]);
9175 5438191 }
9176
9177 // Returns true if any game key is pressed. This is needed because keypressed()
9178 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9179 28178162 bool zc_key_pressed()
9180 //may also need to use zc_getrawkey
9181 {
9182
7/10
✓ Branch 0 taken 22800161 times.
✓ Branch 1 taken 5378001 times.
✓ Branch 2 taken 5378001 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5378001 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4533401 times.
✓ Branch 7 taken 4533401 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1621032 times.
29799194 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9183
4/6
✓ Branch 0 taken 4533401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4533401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3418530 times.
✓ Branch 5 taken 3418530 times.
4533401 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9184
4/6
✓ Branch 0 taken 3418530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3418530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2176173 times.
✓ Branch 5 taken 2176173 times.
3418530 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9185
4/6
✓ Branch 0 taken 2176173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2176173 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1838283 times.
✓ Branch 5 taken 1838283 times.
2176173 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9186
1/2
✓ Branch 0 taken 1838283 times.
✗ Branch 1 not taken.
1838283 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9187
3/4
✓ Branch 0 taken 1736661 times.
✓ Branch 1 taken 101622 times.
✓ Branch 2 taken 1736661 times.
✗ Branch 3 not taken.
1838283 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9188
3/4
✓ Branch 0 taken 1646160 times.
✓ Branch 1 taken 90501 times.
✓ Branch 2 taken 1646160 times.
✗ Branch 3 not taken.
1736661 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9189
3/4
✓ Branch 0 taken 1633476 times.
✓ Branch 1 taken 12684 times.
✓ Branch 2 taken 1633476 times.
✗ Branch 3 not taken.
1646160 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9190
3/4
✓ Branch 0 taken 1623117 times.
✓ Branch 1 taken 10359 times.
✓ Branch 2 taken 1623117 times.
✗ Branch 3 not taken.
1633476 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9191
3/4
✓ Branch 0 taken 1621864 times.
✓ Branch 1 taken 1253 times.
✓ Branch 2 taken 1621864 times.
✗ Branch 3 not taken.
1623117 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9192
3/4
✓ Branch 0 taken 1621821 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 1621821 times.
✗ Branch 3 not taken.
1621864 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9193
3/4
✓ Branch 0 taken 1621051 times.
✓ Branch 1 taken 770 times.
✓ Branch 2 taken 1621051 times.
✗ Branch 3 not taken.
1621821 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9194
2/4
✓ Branch 0 taken 1621051 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621051 times.
✗ Branch 3 not taken.
1621051 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9195
2/2
✓ Branch 0 taken 1621032 times.
✓ Branch 1 taken 19 times.
1621051 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9196 50489904 return true;
9197
9198 1621032 return false;
9199 6510614 }
9200
9201 108529366 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9202 {
9203 108529366 bool ret = false, drunkstate = false, rawret = false;
9204 108529366 bool* flag = &down_control_states[btn];
9205
2/7
✓ Branch 0 taken 102011933 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 6517433 times.
108529366 switch(btn)
9206 {
9207 case btnF12:
9208 ret = zc_getkey(KEY_F12, ignoreDisable);
9209 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9210 eatEntirely = false;
9211 break;
9212 case btnF11:
9213 ret = zc_getkey(KEY_F11, ignoreDisable);
9214 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9215 eatEntirely = false;
9216 break;
9217 case btnF5:
9218 ret = zc_getkey(KEY_F5, ignoreDisable);
9219 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9220 eatEntirely = false;
9221 break;
9222 case btnQ:
9223 ret = zc_getkey(KEY_Q, ignoreDisable);
9224 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9225 eatEntirely = false;
9226 break;
9227 case btnI:
9228 ret = zc_getkey(KEY_I, ignoreDisable);
9229 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9230 eatEntirely = false;
9231 break;
9232 case btnM:
9233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6517433 times.
6517433 if(FFCore.kb_typing_mode) return false;
9234 6517433 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9235 6517433 eatEntirely = false;
9236 6517433 break;
9237 default: //control_state[] index
9238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102011933 times.
102011933 if(FFCore.kb_typing_mode) return false;
9239
5/6
✓ Branch 0 taken 101784203 times.
✓ Branch 1 taken 227730 times.
✓ Branch 2 taken 2257162 times.
✓ Branch 3 taken 99527041 times.
✓ Branch 4 taken 2257162 times.
✗ Branch 5 not taken.
102011933 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9240
2/2
✓ Branch 0 taken 5491613 times.
✓ Branch 1 taken 96520320 times.
102011933 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9241
4/4
✓ Branch 0 taken 91845546 times.
✓ Branch 1 taken 10166387 times.
✓ Branch 2 taken 1395 times.
✓ Branch 3 taken 10164992 times.
112178320 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9242 102011933 rawret = raw_control_state[btn];
9243 102011933 }
9244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108529366 times.
108529366 assert(flag);
9245
2/2
✓ Branch 0 taken 70505419 times.
✓ Branch 1 taken 38023947 times.
108529366 if(press)
9246 {
9247
2/2
✓ Branch 0 taken 1337132 times.
✓ Branch 1 taken 36686815 times.
38023947 if(peek)
9248 1337132 ret = rButtonPeek(ret, *flag);
9249
3/4
✓ Branch 0 taken 36686815 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17001122 times.
✓ Branch 3 taken 19685693 times.
36686815 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9250 17001122 else ret = rButton(ret, *flag, &rawret);
9251 38023947 }
9252
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 108529366 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
108529366 if(eatEntirely && ret) control_state[btn] = false;
9253
3/4
✓ Branch 0 taken 82010678 times.
✓ Branch 1 taken 26518688 times.
✓ Branch 2 taken 82010678 times.
✗ Branch 3 not taken.
108529366 if(drunk && drunkstate) ret = !ret;
9254 108529366 return ret;
9255 108529366 }
9256
9257 5384201 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9258 {
9259 5384201 byte ret = 0;
9260
2/2
✓ Branch 0 taken 4045008 times.
✓ Branch 1 taken 1339193 times.
5384201 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9261
2/2
✓ Branch 0 taken 5383639 times.
✓ Branch 1 taken 562 times.
5384201 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9262
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9263
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9264
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9265
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9266
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9267
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9268 5384201 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9269 }
9270
9271 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9272 {
9273 1114 return intbtn&vals;
9274 }
9275
9276 1281348 bool Up()
9277 {
9278 1281348 return getInput(btnUp);
9279 }
9280 77421 bool Down()
9281 {
9282 77421 return getInput(btnDown);
9283 }
9284 167324 bool Left()
9285 {
9286 167324 return getInput(btnLeft);
9287 }
9288 188659 bool Right()
9289 {
9290 188659 return getInput(btnRight);
9291 }
9292 68115 bool cAbtn()
9293 {
9294 68115 return getInput(btnA);
9295 }
9296 1255212 bool cBbtn()
9297 {
9298 1255212 return getInput(btnB);
9299 }
9300 bool cSbtn()
9301 {
9302 return getInput(btnS);
9303 }
9304 29891 bool cLbtn()
9305 {
9306 29891 return getInput(btnL);
9307 }
9308 29891 bool cRbtn()
9309 {
9310 29891 return getInput(btnR);
9311 }
9312 bool cPbtn()
9313 {
9314 return getInput(btnP);
9315 }
9316 bool cEx1btn()
9317 {
9318 return getInput(btnEx1);
9319 }
9320 bool cEx2btn()
9321 {
9322 return getInput(btnEx2);
9323 }
9324 bool cEx3btn()
9325 {
9326 return getInput(btnEx3);
9327 }
9328 bool cEx4btn()
9329 {
9330 return getInput(btnEx4);
9331 }
9332 bool AxisUp()
9333 {
9334 return getInput(btnAxisUp);
9335 }
9336 bool AxisDown()
9337 {
9338 return getInput(btnAxisDown);
9339 }
9340 bool AxisLeft()
9341 {
9342 return getInput(btnAxisLeft);
9343 }
9344 bool AxisRight()
9345 {
9346 return getInput(btnAxisRight);
9347 }
9348
9349 bool cMbtn()
9350 {
9351 return getInput(btnM);
9352 }
9353 bool cF12()
9354 {
9355 return getInput(btnF12);
9356 }
9357 bool cF11()
9358 {
9359 return getInput(btnF11);
9360 }
9361 bool cF5()
9362 {
9363 return getInput(btnF5);
9364 }
9365 bool cQ()
9366 {
9367 return getInput(btnQ);
9368 }
9369 bool cI()
9370 {
9371 return getInput(btnI);
9372 }
9373
9374 112876 bool rUp()
9375 {
9376 112876 return getInput(btnUp, true);
9377 }
9378 112804 bool rDown()
9379 {
9380 112804 return getInput(btnDown, true);
9381 }
9382 112757 bool rLeft()
9383 {
9384 112757 return getInput(btnLeft, true);
9385 }
9386 112309 bool rRight()
9387 {
9388 112309 return getInput(btnRight, true);
9389 }
9390 2482 bool rAbtn()
9391 {
9392 2482 return getInput(btnA, true);
9393 }
9394 113491 bool rBbtn()
9395 {
9396 113491 return getInput(btnB, true);
9397 }
9398 5266505 bool rSbtn()
9399 {
9400 5266505 return getInput(btnS, true);
9401 }
9402 6510614 bool rMbtn()
9403 {
9404 6510614 return getInput(btnM, true);
9405 }
9406 112109 bool rLbtn()
9407 {
9408 112109 return getInput(btnL, true);
9409 }
9410 112106 bool rRbtn()
9411 {
9412 112106 return getInput(btnR, true);
9413 }
9414 5182404 bool rPbtn()
9415 {
9416 5182404 return getInput(btnP, true);
9417 }
9418 bool rEx1btn()
9419 {
9420 return getInput(btnEx1, true);
9421 }
9422 bool rEx2btn()
9423 {
9424 return getInput(btnEx2, true);
9425 }
9426 122985 bool rEx3btn()
9427 {
9428 122985 return getInput(btnEx3, true);
9429 }
9430 122985 bool rEx4btn()
9431 {
9432 122985 return getInput(btnEx4, true);
9433 }
9434 bool rAxisUp()
9435 {
9436 return getInput(btnAxisUp, true);
9437 }
9438 bool rAxisDown()
9439 {
9440 return getInput(btnAxisDown, true);
9441 }
9442 bool rAxisLeft()
9443 {
9444 return getInput(btnAxisLeft, true);
9445 }
9446 bool rAxisRight()
9447 {
9448 return getInput(btnAxisRight, true);
9449 }
9450
9451 bool rF11()
9452 {
9453 return getInput(btnF11, true);
9454 }
9455 bool rQ()
9456 {
9457 return getInput(btnQ, true);
9458 }
9459 bool rI()
9460 {
9461 return getInput(btnI, true);
9462 }
9463
9464 13317771 bool DrunkUp()
9465 {
9466 13317771 return getInput(btnUp, false, true);
9467 }
9468 12417217 bool DrunkDown()
9469 {
9470 12417217 return getInput(btnDown, false, true);
9471 }
9472 7866450 bool DrunkLeft()
9473 {
9474 7866450 return getInput(btnLeft, false, true);
9475 }
9476 6829749 bool DrunkRight()
9477 {
9478 6829749 return getInput(btnRight, false, true);
9479 }
9480 5759186 bool DrunkcAbtn()
9481 {
9482 5759186 return getInput(btnA, false, true);
9483 }
9484 5722928 bool DrunkcBbtn()
9485 {
9486 5722928 return getInput(btnB, false, true);
9487 }
9488 5152193 bool DrunkcEx1btn()
9489 {
9490 5152193 return getInput(btnEx1, false, true);
9491 }
9492 5152213 bool DrunkcEx2btn()
9493 {
9494 5152213 return getInput(btnEx2, false, true);
9495 }
9496 bool DrunkcSbtn()
9497 {
9498 return getInput(btnS, false, true);
9499 }
9500 bool DrunkcMbtn()
9501 {
9502 return getInput(btnM, false, true);
9503 }
9504 bool DrunkcLbtn()
9505 {
9506 return getInput(btnL, false, true);
9507 }
9508 bool DrunkcRbtn()
9509 {
9510 return getInput(btnR, false, true);
9511 }
9512 bool DrunkcPbtn()
9513 {
9514 return getInput(btnP, false, true);
9515 }
9516
9517 bool DrunkrUp()
9518 {
9519 return getInput(btnUp, true, true);
9520 }
9521 bool DrunkrDown()
9522 {
9523 return getInput(btnDown, true, true);
9524 }
9525 bool DrunkrLeft()
9526 {
9527 return getInput(btnLeft, true, true);
9528 }
9529 bool DrunkrRight()
9530 {
9531 return getInput(btnRight, true, true);
9532 }
9533 4315794 bool DrunkrAbtn()
9534 {
9535 4315794 return getInput(btnA, true, true);
9536 }
9537 4328323 bool DrunkrBbtn()
9538 {
9539 4328323 return getInput(btnB, true, true);
9540 }
9541 71669 bool DrunkrEx1btn()
9542 {
9543 71669 return getInput(btnEx1, true, true);
9544 }
9545 71662 bool DrunkrEx2btn()
9546 {
9547 71662 return getInput(btnEx2, true, true);
9548 }
9549 bool DrunkrEx3btn()
9550 {
9551 return getInput(btnEx3, true, true);
9552 }
9553 bool DrunkrEx4btn()
9554 {
9555 return getInput(btnEx4, true, true);
9556 }
9557 bool DrunkrSbtn()
9558 {
9559 return getInput(btnS, true, true);
9560 }
9561 bool DrunkrMbtn()
9562 {
9563 return getInput(btnM, true, true);
9564 }
9565 4832892 bool DrunkrLbtn()
9566 {
9567 4832892 return getInput(btnL, true, true);
9568 }
9569 4830254 bool DrunkrRbtn()
9570 {
9571 4830254 return getInput(btnR, true, true);
9572 }
9573 bool DrunkrPbtn()
9574 {
9575 return getInput(btnP, true, true);
9576 }
9577
9578 6819 void eat_buttons()
9579 {
9580 6819 getInput(btnA, true, false, true);
9581 6819 getInput(btnB, true, false, true);
9582 6819 getInput(btnS, true, false, true);
9583 6819 getInput(btnM, true, false, true);
9584 6819 getInput(btnL, true, false, true);
9585 6819 getInput(btnR, true, false, true);
9586 6819 getInput(btnP, true, false, true);
9587 6819 getInput(btnEx1, true, false, true);
9588 6819 getInput(btnEx2, true, false, true);
9589 6819 getInput(btnEx3, true, false, true);
9590 6819 getInput(btnEx4, true, false, true);
9591 6819 }
9592
9593 // Is true for the _first frame_ of a key press.
9594 // But! it is possible that a script manually sets the value of KeyPress,
9595 // in which case it will be restored to the "true" value based on `key_current_frame`
9596 // and `key_previous_frame` on the next frame.
9597 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9598 {
9599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9601 {
9602 case KEY_F7:
9603 case KEY_F8:
9604 case KEY_F9:
9605 return KeyPress[k];
9606
9607 default:
9608
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 return KeyPress[k] && !disabledKeys[k];
9609 }
9610 14 }
9611
9612 // Is true for _every frame_ a key is held down.
9613 // But! it is possible that a script manually sets the value of KeyInput,
9614 // in which case it will be restored to the "true" value based on `key_current_frame`
9615 // on the next frame.
9616 bool zc_getkey(int32_t k, bool ignoreDisable)
9617 {
9618 if(ignoreDisable) return KeyInput[k];
9619 switch(k)
9620 {
9621 case KEY_F7:
9622 case KEY_F8:
9623 case KEY_F9:
9624 return KeyInput[k];
9625
9626 default:
9627 return KeyInput[k] && !disabledKeys[k];
9628 }
9629 }
9630
9631 // Reads (and then clears) the current frame key state directly.
9632 // Scripts can also modify `key_current_frame`.
9633 125 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9634 {
9635
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 123 times.
125 if(zc_getrawkey(k, ignoreDisable))
9636 {
9637 2 _key[k]=key[k]=key_current_frame[k]=0;
9638 2 return true;
9639 }
9640 123 _key[k]=key[k]=key_current_frame[k]=0;
9641 123 return false;
9642 125 }
9643
9644 // Reads the current frame key state directly.
9645 // Scripts can also modify `key_current_frame`.
9646 43497761 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9647 {
9648
2/2
✓ Branch 0 taken 36987119 times.
✓ Branch 1 taken 6510642 times.
43497761 if(ignoreDisable) return key_current_frame[k];
9649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510642 times.
6510642 switch(k)
9650 {
9651 case KEY_F7:
9652 case KEY_F8:
9653 case KEY_F9:
9654 return key_current_frame[k];
9655
9656 default:
9657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510642 times.
6510642 return key_current_frame[k] && !disabledKeys[k];
9658 }
9659 43497761 }
9660
9661 // Only used for a handful of keys, like tilde and Function keys.
9662 // This state is never read within the game.
9663 // It exists so that all keyboard input still functions during replay,
9664 // without inadvertently doing things like toggling throttling if the player
9665 // presses ~
9666 13021293 bool zc_get_system_key(int32_t k)
9667 {
9668 13021293 return key_system[k];
9669 }
9670
9671 // True for the _first_ frame of a key press.
9672 58595526 bool zc_read_system_key(int32_t k)
9673 {
9674 58595526 return key_system_press[k];
9675 }
9676
9677 826847978 bool is_system_key(int32_t k)
9678 {
9679
2/2
✓ Branch 0 taken 768252452 times.
✓ Branch 1 taken 58595526 times.
826847978 switch (k)
9680 {
9681 case KEY_BACKQUOTE:
9682 case KEY_CLOSEBRACE:
9683 case KEY_END:
9684 case KEY_HOME:
9685 case KEY_OPENBRACE:
9686 case KEY_PGDN:
9687 case KEY_PGUP:
9688 case KEY_TAB:
9689 case KEY_TILDE:
9690 58595526 return true;
9691 }
9692 768252452 return is_Fkey(k);
9693 826847978 }
9694
9695 6510614 void update_system_keys()
9696 {
9697
2/2
✓ Branch 0 taken 826847978 times.
✓ Branch 1 taken 6510614 times.
833358592 for (int32_t q = 0; q < 127; ++q)
9698 {
9699
2/2
✓ Branch 0 taken 136722894 times.
✓ Branch 1 taken 690125084 times.
826847978 if (!is_system_key(q))
9700 690125084 continue;
9701
9702 136722894 key_system[q] = key[q];
9703
1/2
✓ Branch 0 taken 136722894 times.
✗ Branch 1 not taken.
136722894 key_system_press[q] = key_system[q] && !key_system_previous[q];
9704 136722894 key_system_previous[q] = key_system[q];
9705 136722894 }
9706 6510614 }
9707
9708 7628080 void update_keys()
9709 {
9710
2/2
✓ Branch 0 taken 968766160 times.
✓ Branch 1 taken 7628080 times.
976394240 for (int32_t q = 0; q < 127; ++q)
9711 {
9712 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9713
1/2
✓ Branch 0 taken 968766160 times.
✗ Branch 1 not taken.
968766160 if (!replay_is_replaying())
9714 key_current_frame[q] = key[q];
9715
9716
2/2
✓ Branch 0 taken 961653306 times.
✓ Branch 1 taken 7112854 times.
968766160 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9717 968766160 KeyInput[q] = key_current_frame[q];
9718 968766160 key_previous_frame[q] = key_current_frame[q];
9719 968766160 }
9720 7628080 }
9721
9722 bool zc_disablekey(int32_t k, bool val)
9723 {
9724 switch(k)
9725 {
9726 case KEY_F7:
9727 case KEY_F8:
9728 case KEY_F9:
9729 return false;
9730
9731 default:
9732 disabledKeys[k] = val;
9733 return true;
9734 }
9735 }
9736
9737 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9738 {
9739 timer=timer;
9740 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9741 }
9742
9743 // these are here so that copy_dialog won't choke when compiling zelda
9744 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
9745 {
9746 return D_O_K;
9747 }
9748
9749 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
9750 {
9751 return D_O_K;
9752 }
9753
9754 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
9755 {
9756 return D_O_K;
9757 }
9758
9759 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
9760 {
9761 return D_O_K;
9762 }
9763
9764 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
9765 {
9766 return D_O_K;
9767 }
9768
9769 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
9770 {
9771 return D_O_K;
9772 }
9773
9774 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
9775 {
9776 return D_O_K;
9777 }
9778
9779 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
9780 {
9781 return D_O_K;
9782 }
9783
9784 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
9785 {
9786 return D_O_K;
9787 }
9788
9789 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
9790 {
9791 return D_O_K;
9792 }
9793
9794 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
9795 {
9796 return D_O_K;
9797 }
9798
9799 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
9800 {
9801 return D_O_K;
9802 }
9803
9804 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
9805 {
9806 return D_O_K;
9807 }
9808
9809 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
9810 {
9811 return D_O_K;
9812 }
9813
9814 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
9815 {
9816 return D_O_K;
9817 }
9818
9819 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
9820 {
9821 return D_O_K;
9822 }
9823
9824 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
9825 {
9826 return D_O_K;
9827 }
9828
9829 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
9830 {
9831 return D_O_K;
9832 }
9833
9834 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
9835 {
9836 return D_O_K;
9837 }
9838
9839 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
9840 {
9841 return D_O_K;
9842 }
9843
9844 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
9845 {
9846 return D_O_K;
9847 }
9848
9849 /*** end of zc_sys.cc ***/
9850
9851